How to build Android Archive Library(AAR) with Android Build Tools? - android

I want to build aar files but I dont have Android Studio as my computer cannot run it.
How to build it from command line using the raw build tools; no gradle included?
The steps to build apk are:
generate R.java file with (aapt).
compile src files including R.java with (javac)
dex classes with (dx)
package, sign, align.
I understand that aar manifest(s) are not compiled to binary format. Thus the first step may not work when creating aar libs.
Please, I am begging, how to, the steps to creating with the build tools.

./gradlew <moduleName>:bundle<build_variant>Aar
//for example
./gradlew app:bundleReleaseAar

Related

firebase-crashlytics-ndk: Unstripped native library path required by generateCrashlyticsSymbolFreeDebug does not exist

I am using ...
com.google.firebase:firebase-crashlytics-ndk:17.3.1
com.google.firebase:firebase-crashlytics-gradle:2.4.1
com.google.gms:google-services:4.3.5
... in my Android application project which depends on a Android library project. The library project uses both Kotlin and C-Code. The library build process outputs an *.aar with unstripped *.so files. When I build the application project I can verify that the unstripped *.so files of the library are unpacked into app/build/intermediates/merged_native_libs/<BuildVariant>/out/lib and that they are still unstripped.
The app is configured with the build flavors free and paid and the usual build types debug and release.
First, I assemble the APK via ./gradlew clean assembleFreeDebug.
Then, I invoke ./gradlew generateCrashlyticsSymbolFileFreeDebug which fails:
Execution failed for task ':app:generateCrashlyticsSymbolFileFreeDebug'.
Unstripped native library path required by generateCrashlyticsSymbolFileFreeDebug does not exist: app\build\intermediates\merged_native_libs\PaidDebug\out\lib. Check your configuration, or override using the firebaseCrashlytics.unstrippedNativeLibsDir extension property.
Is this a bug where build flavors are mixed up by the Gradle plugin or a misconfiguration on my side?
I can workaround it if I also assemblePaidDebug without clean. Then, symbol files are generated by generateCrashlyticsSymbolFileFreeDebug in app/build/crashlytics. I am however not sure if it is a good idea to mix the input files (flavors) to generate the *.cSYM files.
Related
:app:generateCrashlyticsSymbolFileRelease error: Unstripped native library path required by generateCrashlyticsSymbolFileRelease does not exist:
try to remove unstrippedNativeLibsDir. If you are building C++ code as part of your app build and not in library, crashlytics should find necessary path automatically
if it's still not working and you're using cmake for build try tu use this path: ./build/intermediates/cmake/release/obj

How do I configure ant on Android to include an external jar without exporting it in the apk?

I Have an application that uses a shared jar library located on my platform. I would like to build my project off my platform. To do so, I need to include the jar file in compilation.
This works in Eclipse - I add the library to the project, and everything works fine. I encounter a problem after building with ant. Ant requires that I include the jar file in my libs directory. However if I include it there, it is exported into the apk. When I deploy this locally built apk to my device, I get runtime errors complaining about multiple symbol definitions.
Try to add a custom_rules.xml file to your project to exclude jar after compilation from apk. See here Exclude dependency jar file from apk when using Ant for Android

Android gradle build includes jni libs twice

I've been trying to solve a problem about Android build, but couldn't figure out how to solve it.
Basically, I am trying to build an Android project using Gradle. It works perfect, but the size of the final apk is 7MB more than when I builded with Eclipse.
When I unzip the apk, I see that the JNI Libs are included twice. Which is different from the Eclipse build that includes it only one time. Here is the paths I can find them in the APK:
lib/armeabi
lib/armeabi-v7a
main/jniLibs/armeabi
main/jniLibs/armeabi-v7a
In my project, those two files are in:
android/app/src/main/jniLibs/armeabi
android/app/src/main/jniLibs/armeabi-v7a
I have two different build.graddle files in:
android/
android/app/
None of them contains anything related to the JNI Libs.
To build a release, I use the command:
./gradlew assembleRelease
And everything works fine. I use Gradle 1.10.
I was wondering if someone ever encountered the problem and find a solution to avoid to the JNI Libs to be included twice in the APK.
Thanks :)
Put .so files in...
/src/main/jniLibs/armeabi-v7a
/src/main/jniLibs/x86
directories and gradle will correctly package the .so files into the correct app and it won't include the duplicates
This is a good reference..
http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/

Building android project with ant

I am trying to build my android project using ant in command line mode.
It works with eclipse and it used to work with ant until i installed the latest android sdk.
I run ant release -buildfile projectdir\build.xml. The compilation process is ok, and after aligning the apk, it fails at runtime with ClassDefNotFoundError acra.ACRA.
I have tried to remove any reference to acra from the project, but it will fail at runtime when trying to execute any code coming from a library jar.
My jars are in the libs folder at the root of the project. And I sort of understood this would cause ant to link them into the apk. But it doesn't.
When I used a previous version of the android sdk, I had a file named build.properties with an attribute referencing the jars folder external.libs.dir=libs. But now I can't make this to work any more, even if I use the new attributes names jar.libs.dir=libs and the new attributes file name ant.properties.
I read that ClassDefNotFoundError is caused because at compile time the librairies are found, but they are not linked into the apk, so they can't be found at runtime.
How can I link the external jars in the apk please ?
The compilation process is ok, and after aligning the apk, it fails at runtime with ClassDefNotFoundError acra.ACRA
There is no acra.ACRA class in ACRA, at least not in the current edition. It's org.acra.ACRA.
My jars are in the libs folder at the root of the project. And I sort of understood this would cause ant to link them into the apk. But it doesn't.
Yes, it does. Then ProGuard is removing them, unless you teach ProGuard not to.

Managing android projects from command line

I am managing and running my android app from command line without using ant, I followed these steps:
generate R.java
compile R.java and all .java files in src to .class files
assembling set of class files into dex file using the command below
dx --dex --verbose --output=./bin/classes.dex ./bin
.class files are in bin directory.
But I'm getting the following errors in these steps:
java.lang.Runtime exception:.\bin file not found
at com.android.dx.cf.direct.ClassPathOpener.process
at com.android.dx.command.dexer.Main.processOne
at com.android.dx.command.dexer.Main.processAllFiles
at com.android.dx.command.dexer.Main..run
at com.android.dx.command.dexer.Main.main
at com.android.dx.command.Main.main
Due to this, I'm unable to create the Classes.dex file.
Can someone suggest a solution for this?
[not using eclipse and ant only through command line]
If you need to "manage your Android projects from command line", when you should use Ant build.
Ant's build.xml is a official standardized way to build Android projects. Ant scripts can do anything you may need to build your project.
If you want most modern build tools for Android, you can look at Gradle for Android projects. Note: today it's still in alpha stage.
Try entering the full path instead of the relative path.
Also you must put the class files inside a directory named exactly like it's package name. for example for com.test.me.MyActivity you must use com/test/me/MyActivity.class
And since we are on the topic, remember that dx can only work with class files created using Java6 (or less) so if you are using java7 to compile your code, add "source 1.6 target 1.6" parameters to your command line.

Categories

Resources