Reputation: 556
I'm trying to build apk manually (without gradle) according to this manual, but I don't understand how to use libraries with resources. I've downloaded Android Support Library, unzipped appcopmpat
directory and specified -classpath
in javac
. I'm trying also to specify path to resources in aapt
, but it reports name conflict. Should I just rename my app's resources, or is there a better solution?
Here's the command ($MANIFEST
and $ANDROID
are just paths):
aapt package -f -m -J app/src -M ${MANIFEST} -I ${ANDROID} -S appcompat/res app/res
And the error message:
app/res/values/strings.xml: error: Duplicate file.
appcompat/res/values/strings.xml: Original is here.
Upvotes: 3
Views: 1915
Reputation: 384
The following command can be used:
aapt package -f -m -J app/src -M ${MANIFEST} -I ${ANDROID} -S app/res -S appcompat/res --extra-packages android.support.v7.app --auto-add-overlay
-S option before appcompat/res enable compiling code needed for app/res folder. --auto-add-overlay enables support libraries resources to be overlayed on above of main app. --extra-packages option for enabling R.java for appcompat too, so that appcompat will work correctly.
A working script can be found here https://github.com/HemanthJabalpuri/AndroidExplorer
Upvotes: 1
Reputation: 33
You can use --auto-add-overlay
for duplicate resources but the problem is that, it is very difficult to figure out the proper resources commands and use. You also need to specify multiple -S
res path for external Support Library, which are included in res inside .aar
zip file.
Also, you can use --extra-packages <package_name>
where you replace <package_name>
with any package name, e.g. com.foo.bla. This will create an additional R.java
file of the package. Instead of using a support library (e.g. AppCompatv7), you can use a theme available in android.jar
which you would be using in main Manifest.xml
, pointing a theme to Styles.xml
in values folder. In this case, you would be able to use 'AAPT' tool without any support library.
Here is an article to create APK in a best way: https://geosoft.no/development/android.html.
See my answer on a similar question to use android's general theme (not available in a support library), so that you wouldn't have to integrate other libraries: How to compile an Android app with aapt2 without using any build tools?
Upvotes: 3