Can I add new package under the folder \scr in android? - android

I create an app with package name info.dodata.smsforward and eclipse create a default file construction just like Old.PNG.
I think the file construction under the folder \scr is not good, so I add three packages name BLL, DLL ,UI and place different classes file into different package name just like New.PNG.
My question are
A: Can I add new package under the folder \scr. You know there is only one package="info.dodata.smsforward" in AndroidManifest.xml, I don't konw if only one package name is allowed in one android app.
B: Are my packages name too short? Do I need add my domain before package name BLL, DAL and UI. Will the short package name (such as BLL, DLL) conflict with other APP?
Old ModePublic.java
package info.dodata.smsforward;
public class ModePublic {
public final static int DBVersion=2;
public final static String DBName="smsforward.db";
}
Old AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.dodata.smsforward"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="info.dodata.smsforward.UIMain"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
New ModePublic.java
package DAL;
public class ModePublic {
public final static int DBVersion=2;
public final static String DBName="smsforward.db";
}
New AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.dodata.smsforward"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="UI.UIMain"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

A. Yes you can, as many packages you like as deep as you like.
B. There are no rules on this. It's hard for other people to understand what you mean with such short names. So when working with more people it's probably better to have nicer names. They won't conflict with other apps because they only exists within your initial package name directory. (manifest)
Note: The AndroidManifest.xml package name serves as a unique identifier for the application. And create the initial folders where classes are generated in. For example bin/classes/info/dodata/smsforward/ Java packages are essentially just folders in src directory. You use those to bundle your interfaces and classes.

Yes i agree with #tim
A: You can add any number of sub packages inside a package - no issues
B:
You cannot add the main package name as BLL or DLL. The android need a main package name with at least 2 identifiers, so as to apply the application in google play store.
Only main package should be with 2 identifier, all other package names can be any type.
But good android coding approach should have a main package as com.xxx and other packages will be like com.xxx.view, com.xxx.activity, etc

Related

implementing Ubers usebutton sdk and AndroidManifest.xml

I am trying to use the Uber usebutton but each time, it crashes giving the following error:
Unable to find explicit activity class {com.heyjude.heyjudeapp/com.usebutton.sdk.internal.GroupedInventoryCardActivity}; have you declared this activity in your AndroidManifest.xml?
I am unsure what to put in the AndroidManifest, currently as per the docs I have:
<meta-data
android:name="com.usebutton.applicationid"
android:value="app-myId" />
But it's clearly not working...
I have some more information, I checked the manifest-merger-debug-report.txt and found the following line
REJECTED from [com.usebutton:android-sdk:5.0.1] /Users/adamkatz/Projects/LavaLamp/Hey Jude/heyjudestudio/app/build/intermediates/exploded-aar/com.usebutton/android-sdk/5.0.1/AndroidManifest.xml:13:5-43:19
Why would the library manifest be rejected and how to make it accepted?
The maifest stuff maybe a red herring, your probably missing a library (The Uber library).
Here's a typical (working) AndroidMainfest.xml.
VERY important:
package="com.example.html2pdf"
replace with your package name (it's normally in your (local package) GroupedInventoryCardActivity.java file).
VERY important: Html2pdfActivity"
replace with one entry for activity for all your Activity files .GroupedInventoryCardActivity in your case (full path best package plus activity with dots (full stop's separating things, normally no slashes).
VERY VERY important:
com.heyjude.heyjudeapp/com.usebutton.sdk.internal.GroupedInventoryCardActivity is reffering to a library Activity (also with a package name the forward slash links the two packages). That's o.k.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.html2pdf"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.html2pdf.Html2pdfActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
So package (replace/change):
package="com.heyjude.heyjudeapp"
and (replace/change/insert) Activity (name):
<activity
android:name="com.heyjude.heyjudeapp/com.usebutton.sdk.internal.GroupedInventoryCardActivity"
Hope this helps and not make it more confusing ;O)
All that goes into the AndroidManifest.xml file is this:
<application
<activity
<!-- your activities -->
</activity>
<!--Button SDK-->
<meta-data android:name="com.usebutton.applicationid" android:value="YOUR_BUTTON_APP_ID"/>
</application>
Did you remember to replace "YOUR_BUTTON_APP_ID" with your Button app ID found in the dashboard?

In Android XML, what is the significance of a period (".") preceding a class or package reference?

While browsing the Android developer docs I spotted example code where references to classes/packages are preceded by periods.
In the snippet below from http://developer.android.com/guide/topics/search/search-dialog.html there is ".SearchableActivity"
<application ... >
<activity android:name=".SearchableActivity" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="#xml/searchable"/>
</activity>
...
</application>
Another example - http://developer.android.com//training/sharing/receive.html - has ".ui.MyActivity"
<activity android:name=".ui.MyActivity" >
What do these preceding "." imply, and when/why should/would you use one? What happens if they are ommited?
android:name
Quoting docs
The name of the class that implements the activity, a subclass of
Activity. The attribute value should be a fully qualified class name
(such as, "com.example.project.ExtracurricularActivity"). However, as
a shorthand, if the first character of the name is a period (for
example, ".ExtracurricularActivity"), it is appended to the package
name specified in the element. Once you publish your
application, you should not change this name (unless you've set
android:exported="false").
If in manifest you have
package="com.example.layout"
And your Activity is under the same package you can have
<activity
android:name=".ActivityName"
Instead of ShortHand You can also have
<activity
android:name="com.example.layout.ActivityName"
If the activity is not declared right in manifest you end up in ActivityNotFoundException
If your activity is in a different package then you mention the fully qualified class name
<activity
android:name="packagename.ActivityName"
Note: There is no default. The name must be specified.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity android:name=".DownloadActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
See the above example manifest file
Here "." means a package name
means following line
<activity android:name=".DownloadActivity" >
you can write 2 ways
<activity android:name="com.example.DownloadActivity" > and
<activity android:name=".DownloadActivity" >
in your manifest file you already declare the base package name on top
package="com.example"
so android gives us a way to make it short
so if you use "." for class names it will take the package name that you have defined on top of the manifest file and system take it as com.example.DownloadActivity

Element type "application" must be followed by either attribute specifications, ">" or "/>" #2

I keep getting an error that says, "Element type "application" must be followed by either attribute specifications, ">" or "/>"."
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thenewboston.sammy"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
I'm getting the error right below this:
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is the right form, see if you didn't close some tags.
<application android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
...>
<activity ...>
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
As my friend said , check the right format
For me It was like this :
BEFORE :
<activity android:name=".DisplayMessageActivity" android:label="display_message_activity"
</activity>
AFTER:
<activity android:name=".DisplayMessageActivity" android:label="display_message_activity" >
</activity>
Then the error disappeared
In my case, a comment had been placed (by the build tools?) inside the application tag:
<application android:allowBackup="true"
<!-- android:debuggable="true" -->
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/GdxTheme">
After I removed the entire debuggable=true comment line - everything worked.
I just ran into this error for a completely different reason. For some reason Android Studio had replaced every instance of the string name with "name" (e.g. it wrapped them all in double quotes) in my XML. It completely broke everything.
I had to clear out the double quotes from everything, clean the project and rebuild it.
If you're a flutter developer and you're getting this exception you must know there are two AndroidManifest file in your flutter project. One is inside debug folder and another one is main folder. My main folder AndroidManifest is ok and well formatted but AndroidManifest in debug folder is not ok and not well formatted due to a git conflict.
you must fix this.

Importing android projects that do not have android manifest file

I am currently busy in designing a custom view for my major project. I ran through custom view tutorial provided at developer.android.com . I downloaded the associated sharable project because it gets easy to handle and understand the mechanism of the application when source code is in front of you. To my surprise, the project only contains two folders, src and res and there was no android-manifest file. I tried normal import method, import from existing code and createing new project from exsting android code, no luck with any of the methods. Here the link for the project.
Can somebody please explain to me how I can get it working ?
Can somebody please explain to me how I can get it working ?
Create an empty Android project. Copy in the res/ and src/ from the ZIP file. Modify the manifest to point to the activity class that you copied from the ZIP file.
Create a new empty android project. Copy all resources and source files to your project folder.
http://developer.android.com/guide/topics/manifest/manifest-intro.html.
Goto AndroidManifest.xml define activities and permissions accordingly.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="package name"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="packagename.MainActivity"//your mainactivity
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="packagename.SecondActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="packagename.SecondActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>

Cannot upload an .apk file to the market

I have developed a new application for Android and my application is completed. It doesn't have any errors except for a few (2) harmless warnings. I created an .apk package using the tools available in ECLIPSE. It created a key and an .apk file. Created all right. BUT when I upload the .apk file I get an error telling that I cannot use the following in front of the package name :[com.android,com.goolge,android,com.example]
Below is my manifest details
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.Scheduler"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:icon="#drawable/icon"
android:label=".SchedulerActivity" >
<activity
android:label="#string/app_name"
android:name=".SchedulerActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".addSubject"/>
<activity android:name=".Assignment"/>
<activity android:name=".CameraTake" android:screenOrientation="landscape"/>
<activity android:name=".view_details"/>
<activity android:name=".about"/>
<activity android:name=".help"/>
<activity android:name=".MyAlarmService"/>
<activity android:name=".Assignment_view"/>
<receiver android:name=".MyAlarmService" />
</application>
I tried some methods that are explained in here but it didn't work. Can anyone help me?
It is because of
package="android.Scheduler"
that you are getting this problem.
Notice in your file browser that you probably have src > android > scheduler
you cannot have android there.
all I can think of for a quick fix, is start a new project FROM that one, and in the setup set the package name to com.something.yourappname, but where "something" is do not include "google" or "android"
You have choosen incorrect package name "android.Scheduler", just change your package name.
For eg. if your name is "ravi" then choose package name something like this-
"com.ravi.scheduler".
Steps change package name (eclipse):-
Under your project folder just go to "src" then here you found "android.Scheduler" right click on it, choose "Refactor" -> "rename" & then write your desired package name like "com.ravi.scheduler" & click OK.
Now Rebuild/Run your project & then do application signing.
Now you are ready to upload your app to Google Play.

Categories

Resources