I am trying to build an android application from the command line (the one described at "Minimal" source files to create Android app using Eclipse + ADT ) and aapt is failing with some errors.The errors look like:
AndroidManifest.xml:1: error: No resource identifier found for
attribute 'versionCode' in package 'android'and are repeated once
for each attribute in AndroidManifest.xml.
The command I am running is:aapt package -M AndroidManifest.xml -S res -J genSo I think I am somhow failing to define for aapt where to look for resource identifiers. Is this correct?How do I tell aapt where to look for resource identifiers?I am running Android Asset Packaging Tool, v0.2.
Thanks, Jim.
edit:I should have included a link to the page with the source I copied:http://stackoverflow.com/questions/11888398/minimal-source-files-to-create-android-app-using-eclipse-adt
The Best example I found on Internet so far to create android app is https://geosoft.no/development/android.html also in case if you are using support libraries app theme, it would be difficult to figure out how to create R.java classes, I would suggest you to use this reference answerHow to compile an Android app with aapt2 without using any build tools? by which you will be able to use android.jar's general theme without any dependency on any support library.
Related
I'm trying to build android app bundle from the command line using bundletool following the instruction described in https://developer.android.com/studio/build/building-cmdline#bundletool-build
A simple android project that created basically from Android Studio is used to investigating which one compiled successfully on Android Studio.
The step to have compiled resources is ok, but it's failed on link step with aapt2. Tested with aapt2-3.4.0-5326820-windows
The command:
set ANDROID_TOOL=%ANDROID_SDK%/platforms/android-26/android.jar
%AAPT2% link --proto-format -o output.apk -I %ANDROID_TOOL% --manifest %CURRENT_DIR%/app/src/main/AndroidManifest.xml -R #compiled_resources.txt --auto-add-overlay -v
compiled_resources.txt is containing the list of .flat compiled resources that I processed before.
The error:
error: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.example.doandominh.simpleaab:style/Theme.AppCompat.Light.DarkActionBar) not found.
I:\RnD\AAB\SimpleAAB\\app\src\main\res\values\styles.xml:6: error: style attribute 'attr/colorPrimary (aka com.example.doandominh.simpleaab:attr/colorPrimary)' not found.
I:\RnD\AAB\SimpleAAB\\app\src\main\res\values\styles.xml:7: error: style attribute 'attr/colorPrimaryDark (aka com.example.doandominh.simpleaab:attr/colorPrimaryDark)' not found.
I:\RnD\AAB\SimpleAAB\\app\src\main\res\values\styles.xml:8: error: style attribute 'attr/colorAccent (aka com.example.doandominh.simpleaab:attr/colorAccent)' not found.
error: failed linking references.
I thought it's depending to something like 'com.android.support:appcompat-v7:26.1.0' but I don't know how to add them to aapt2 link parameters.
Does anyone meet this problem before? Any comment is highly appreciated.
tldr: You also need to compile AppCompat resources since you're building all of this by hand, and pass them to link the same way you do with your local resources (the order matters to keep the correct overlays/overrides).
The way the Android Gradle Plugin handles resources in an app level is:
merge all the resources (local app, local libraries, remote libraries, extra resource source-sets etc)
compile everything using 'aapt2 compile' (with or without PNG crunching)
link everything into an APK
I have to use 2 ANEs in my android project.
When I attach 2nd ANE Flash Builder shows a lot of such problems:
Error occurred while packaging the application:
aapt tool failed:C:\Users\***\res\layout\anesample.xml:8: error: Error: No resource found that matches the given name (at 'text' with value '#string/cnn').
All of them are with #string problem.
All strings are present and in the res\values\strings.xml.
Both ANEs work well in another project but I could not find a difference between this projects.
What's wrong?
ANEs work fine together fhen I recompiled one of them with different name of strings.xml, i.e. srings-fb.xml.
But you can imagine situation when every ANE library is compiled not by yourself…
I'm trying to get an (inherited) Android project to build. I'm using Ant & command line tools (and IDEA).
In styles.xml, there are references that cannot be resolved such as:
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
This is the original error I ran into:
[...]/res/values/styles.xml:8: error: Error retrieving parent for item:
No resource found that matches the given name '#style/Theme.AppCompat.Light'.
I then noticed that project.properties has this appcompat reference which is broken on my (OS X) machine:
target=android-18
android.library.reference.1=../../../../adt-bundle-linux-x86_64/sdk/extras/android/support/v7/appcompat
I tried to fix that by making the reference relative to ${sdk.dir}:
android.library.reference.1=${sdk.dir}/extras/android/support/v7/appcompat
So now that path should be correct. But now when I run ant debug:
BUILD FAILED
/opt/android-sdk-macosx/tools/ant/build.xml:573:
/opt/android-sdk-macosx/extras/android/support/v7/appcompat resolve to a
path with no project.properties file for project /Users/joka/devel/project/
So, any ideas? What's the simplest way to get this project built?
(Please note that Ecplise-specific advice won't be useful to me.)
Edit: The Android SDK installation looks like this:
As Jay indicated, only relative paths will work on Unix/Mac.
For the Ant build to work, I also needed to generate build.xml for the appcompat project, using the command android update project -p <dir>, in my case:
/opt/android-sdk-macosx/tools/android update project
-p /opt/android-sdk-macosx-r22.0.1/extras/android/support/v7/appcompat
The exact config for me was:
android.library.reference.1=../../../../../../../opt/android-sdk-macosx/extras/android/support/v7/appcompat
(This also works in local.properties, which I think is a better place since the same path won't work for all developers.)
I merely promoted my comment from 6 months ago into an answer as someone suggested.
By the way, now that I actually know something about Android development, I'd urge anyone who has the chance to ditch Ant and look into the new Gradle-based build system which is totally sweet in comprarison. It is CI-friendly and makes it easy to automate useful things (like using different package name and app icon for different build types). Stack Overflow will help when you run into problems.
Using the support libraries with Gradle, you'd skip all the above hassle and simply do:
dependencies {
compile "com.android.support:appcompat-v7:18.0.+"
}
I ran into the same problem, so I tried using a relative path and that fixed the problem for me. It looks like only relative paths work with android.library.reference. I did a quick search to verify this, and came across this stackoverflow link which indicates that absolute paths will work with android.library.reference on Windows, but not on Unix or Mac.
Peace.
Your path seems to be wrong (you are missing the 'compatibility' part).
The v7-appcompat library is at
{sdkpath}/extras/android/compatibility/v7/appcompat
for me (SDK Tools version 22.0.5 on Max OS X 10.7.5)
I have been told that there is a way to use aapt's --version-code option to add/insert a version code into an APK whose manifest doesn't define one. However, I haven't found any examples of people doing this (except for https://groups.google.com/forum/#!msg/adt-dev/XjehZDzfXhk/g2sWBC37_I4J, which links to a dead page and isn't even the same thing I am trying to do) if indeed it is possible to do.
Currently aapt d badging example.apk run on the apk in question returns something like
package: name='com.example.core' versionCode='' versionName='1.0.0'
sdkVersion:'8'
In my manifest I currently have the versionName defined as a string in an xml file, so I can pull it in with something like android:versionName="#string/app_version_name" (inside the manifest tag). However, if I try this with the version code it doesn't seem to want to resolve the reference. It tries to literally set the version code to the path I enter and then fails as it isn't an integer.
I've tried to do something like aapt p --version-code 100 example.apk but it seems to want to package up a whole project and expects a directory of files as input, not an apk file. (I assume that is the default behavior of aapt p[ackage])
Is it possible to set the version code of an APK after it has been built using the aapt tool? If so, what is the correct syntax?
This solution will not use aapt directly, but it will behind the scenes.
You can use Android APKTool to open you APK, alter the AndroidManifest.xml file, adding the version info; and then use APKTool again to repack. That tool is opensource and uses aapt. Thus you can look at its code to figure out how to do it using aapt directly.
I am playing with the new google expansion pack stuff, and the google library project for the downloader has a special values-v9/styles.xml file for the notification text properties. This causes an error when the app that is using the library is preAPI9... at least for me. It is referring to some style stuff that only appeared in api9. I've tried setting
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="9" />
in the AndroidManifest.xml of the main app, but this didn't help. I would (naively) hope eclipse would just ignore the error if I'm building for api8, and then when deployed on the market the system would use the values-9 stuff if the phone were at or above that level, but it doesn't seem to work that way. So, I'm hoping I'm missing something trivial here.
btw - here are the specific errors
Description Resource Path Location Type
error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.StatusBar.EventContent.Title'. styles.xml /Google Play Downloader Library/res/values-v9 line 4 Android AAPT Problem
Description Resource Path Location Type
error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.StatusBar.EventContent.Title'. styles.xml /Google Play Downloader Library/res/values-v9 line 4 Android AAPT Problem
Yes, I'm getting this also. I posted a related question here:
Android apk expansion file libs problems
I'm stumped to know what to do.
Update:
This worked for me. I deleted the values-v9 folder and rebuilt everything. The DownloadManager is now working. How, I don't know.
Try changing build target via Project->Properties->Android AND/OR Clean your project via Project->clean...
This worked for me after having to manually create the styles.xml file inside the styles-v9 folder through windows explorer.
I've fixed this error by building the project with the following commands:
android update project -p . -t 3 --target android-10
ant release
The first command tells to use the Android 2.3.3 toolchain for buiding the project.
Note that I still have android:minSdkVersion="8" in AndroidManifest.xml.
You should not delete the values-v9/ folder. Removing it can cause displaying notification with dark font on dark background.
If you download the latest api version, you should be able to build the library project against that correctly.
At runtime, Android will discard any code that doesn't work with the api on the device (you'll see various log messages about this), and ignore any res folders with a too high version number. Watch out for the v11 notification code, however: it only works on v14 and above so you'll have to change the code which decides which notification to use.