Two AndroidManifest.xml files, which one is relevant - android

I am learning to develop android apps from android site. As you can see here they talk about AndroidManifest.xml . My project seems to have two such files , with diffferent content.
One located at : workspace\MyFirstApp
Having contents
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:debuggable="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.myfirstapp.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>
</application>
ANother located at workspace\MyFirstApp\bin and having below contents , in addition to what the first file has
<activity
android:name="com.example.myfirstapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
I am not sure why there are two AndroidManifest.xml . Also which one is my main one being used by my project?

This workspace\MyFirstApp\bin is automatically build on Build where as
workspace\MyFirstApp this is your projects Manifest which you can modify and alter this is you main Manifest
Note: *Bin* and Gen Contents are automatically generated You shall not bother about them you can check by Cleaning the project both got emptied and on Rebuilding or Running again Gen and Bin Contents are recreated

bin folder is automatically created when you run your application.You don't need to bother about that.The original Android manifest file is the one in your work space.You can make all possible changes there and when you run your application it will automatically reflect in your bin folder.

Related

how to push additional required files to the app directory?

I am new to Android Development , I was googling for this answer , but a lot of things are just how to upload music and stuff to your device.
Some information
I have a an app that compiles to c++ which will run on the device when I push it with gradlew installDebug . The problem is that I want to add some dependencies that are rather large making about 1G in file space.
I noticed that I cannot write at all to the /data/app/app-name directory when I tried to use adb push files.
Is there a way to have them moved to there during the install or how should this be handled? Keep in mind my app is written in C++ and used the ndk-builder to crosscompile .
In short:
Ideally, I would like the user to have the ability to just have all the files he needs when the application is installed. How can/should I do this?
So the answer is you can add files to your /data/app/res/ folder upon install , but it has to be small I think less than 100MB.
You can just user permission tag to the manafest and store the data in /sdcard/Yourcreatedfolder then access it like any other directory in C.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pvallet.com.github.hello_sdl2">
<application
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
>
<activity
android:name=".HelloSDL2Activity"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateVisible|adjustResize"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>

Android Studio doesn't recognize MainActivity though declared in AndroidManifest.xml

After pausing with work on an Android Studio project for a while, and then coming back and adding it to SVN, I can't get the project to run anymore; it seems to me that the original AndroidManifest.xml was probably lost due to a lack of proper "SVN ignore" rules, and as I created a new Android Studio project on a new machine, updated it from SVN and later commited (and also unfortunately already updated on the other machine I work on), it seems that SVN used the newer manifest file and maybe other files needed for a proper build of the project.
Besides the fact that in the current manifest file, there are several activites missing that I'll have to try to reconstruct there, I now have the problem that I always get the "Default Activity not found" error when trying to build. When I set it to .MainActivity (which is absolutely present in app/src/main/java/com.example.bla.logintest) it says "The activity 'MainActivity' is not declared in AndroidManifest.xml" and thus doesn't compile.
My manifest file now looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bla.logintest" >
<uses-permission android:name="android.permission.READ_PHONE_STATE">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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=".EditDB"
android:label="#string/title_activity_edit_diags"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
<activity
android:name=".EditAnswers"
android:label="#string/title_activity_edit_questions"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
</application>
</uses-permission>
</manifest>
Note: I already tried the solutions in [this similar question][1].
[1]: Default Activity not found in Android Studio "this similar question". Rebuilding and invalidating the cache doesn't get me anywhere. I also added
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
to my build.gradle, and this also didn't change anything.
I am aware that the parent to the other 2 activities is still missing and wanted to work on that problem next, but first wanted to have a working default activity.
Do you have any suggestions what I could try? I'm using Android Studio 1.3.2.
This should solve your problem.
You shouldn't write the tag inside the tag.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bla.logintest" >
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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=".EditDB"
android:label="#string/title_activity_edit_diags"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
<activity
android:name=".EditAnswers"
android:label="#string/title_activity_edit_questions"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
</application>
</manifest>

Upload APK, google store - different package name

I am receiving this error whenever I try to upload my project to google play. However, I recently did a refactor - rename on my project package - "com.mike.myapplication1_0". I cleaned and rebuilt the file but I am still getting this error. I also updated the Manifest file as well...
Here is my manifest -
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.solomichael.myappppppp" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="com.solomichael.myappppppp.MyAndroidAppActivity"
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="com.solomichael.myappppppp.probability_act"
android:label="#string/title_activity_probability_act"
android:parentActivityName="com.solomichael.myappppppp.MyAndroidAppActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.michael.myandroidappactivity.MyAndroidAppActivity" />
</activity>
<activity
android:name="com.solomichael.myappppppp.showOldCards"
android:label="#string/title_activity_show_old_cards"
android:parentActivityName="com.solomichael.myappppppp.MyAndroidAppActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.michael.myandroidappactivity.MyAndroidAppActivity" />
</activity>
</application>
The package name should be unique (across google play store!) so it seems that someone else already used : com.example or com.mike.myapplication1_0 you'll have to choose another name!
Comment:
If you already have an app in the app-store and you change the package name and re-upload the apk - you lose all your current users (their app won't get updated!)
In the <meta-data> elements of two of your Activities you have attributes starting as follows...
android:value="com.example.
I'm not entirely sure why you have <meta-data> elements for those Activities but you either need to change the values to reflect your package name or simply delete the <meta-data> elements completely unless they're absolutely necessary.

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>

Creating java packages for Android projects

I created multiple packages to better structure our Android-based project. After creating these packages, the application no longer runs. It's a widget application. I noticed that the application manifest needed to be modified and did so. This didn't seem to fix the problem. I don't get any error messages, I'm simply not able to open the main activity page from the application widget. Could anyone tell me how to resolve this issue?
For more detail, I initially had a flat project structure (com.domain.A). Now I have the following:
com.domain.Activities
Activity1.java
Activity2.java
com.domain.Features
Feature1.java
Feature2.java
com.domain.Services
Service_1.java
Service_2.java
etc...
Here's an excerpt from the manifest file:
<activity android:name="com.domain.Activities.Activity1"
android:theme="#style/Theme.D1"
android:label="#string/act1"
/>
<activity android:name="com.domain.Activities.Activity2"
android:theme="#style/Theme.D1"
android:label="#string/act2"
/>
<activity android:name="com.domain.Features.Feature1"
android:theme="#style/Theme.D1"
android:label="#string/fea1"
/>
<activity android:name="com.domain.Features.Feature2"
android:theme="#style/Theme.D1"
android:label="#string/fea2"
/>
<service android:name="com.cmu.Services.Service_1"/>
<service android:name="com.cmu.Services.Service_2"/>
Thanks.
After moving the classes in packages, how have you defined the activities in the manifest.
(as a thumb rule ctrl+click on activity declaration in manifest should take you to class file, else link is broken), its generally better to keep all classes extending Activity in main android package of your app
EDIT:
if your MyActivity lies under package a.b;
then .a.b.MyActivity is to be used for android:name in manifest the dot(.) initially specifies to use package-prefix from manifest package name..
You specify a package in your manifest, then you can just use the . prefix to reference the package for the Activities you define in you manifest. So for example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domain"
android:versionCode="1"
android:versionName="1.0" >
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".activities.MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.Activity1" />
<activity android:name=".activities.Activity2" />
You main launcher activity is thus: com.domain.activities.MainActivity and the other two are: com.domain.activities.Activity1 and com.domain.activities.Activity2

Categories

Resources