Android Studio not including latest JNI libraries on Build -> Rebuild - android

There is some issue with android studio. My changes to the native code(library) are not getting effected on rebuild project. Following are the steps I am following.
Remove the existing libraries (rm -r jniLibs/* rm -r obj/local/*)
clean the project
make the project.
Run the app
I have to repeat the above steps 4 to 5 times and then my changes are seen. I am pretty sure I am missing something. Can you guys help me out if i need to change any configuration or something..
Here is the ndk command I am using..
ndk-build NDK_LIBS_OUT=./app/src/main/jniLibs
The above command is building my native code and is properly creating library in jniLibs folder. I am loading this library from my Java source code.

Related

How to run gradle build manually on a flutter project

Currently, I am getting "Finished with error: Gradle task assembleDebug failed with exit code 1" while trying to build a Flutter project (flutter run). The logs do not help much. Therefore, i want to run "gradlew build" or similar manually with stacktrace option to see what is happening under the hood. What is the command for that ?
For posterity I will post my comment as an answer too and I'll elaborate it a bit.
When you create a flutter project there are two new folders created inside the main folder, one is android and one is ios.
The android folder contains the Android native code and all the android configurations, you can handle it as a native android project.
The ios folder contains the iOS native code and all the ios configurations, it also has the xcworkspace file which can be opened with Xcode like a normal ios project.
Now you can run platform specific commands in each folder, like i said, the folders contain actual native projects.
So for Android you could do:
cd android/
./gradlew clean
./gradlew build
(clean and build the project)
For iOS you could do:
cd ios/
pod repo update
pod install
(update the pod repo and install the pods)
Just a short reminder, if you want to create apk/ipa from the native folders, don't forget to run flutter build in the main folder, otherwise you might get outdated code in your apk/ipa.
Go to the folder where you have gradle installed(the place where your GRADLE_HOME variable points to).
Move inside the wrapper folder
Move inside the dists folder which is inside the wrapper folder
Delete everything that you can find inside the dists folder(cached gradle wrapper)
Run/launch your android flutter project again. It should re-download the gradle wrapper and if you don't have any connection problems your project should run correctly.
Note: I'm having the same problem because of my unstable internet connection. I'm ending up with a corrupted gradle wrapper file and the download doesn't restart.
If the download gets interrupted and fails to completely download and launch your project repeat all of the steps.

Cannot update project from terminal in Android

I am developing an Android project. In my project, I need to do OCR. So found this tutorial http://www.codeproject.com/Tips/840623/Android-Character-Recognition. I am trying to follow that tutorial. But I am having problems with set up, especially with updating project from terminal (tess-two folder). See what I have done below.
I downloaded tess-two from this link
https://github.com/rmtheis/tess-two/
Then I installed android NDK to build that project
I set environment variable under PATH
Then I run below command in tess two folder from terminal
ndk-build //this took around 30 minutes. I closed command windows after successful built
Then I run this command
android update project --path C:\tess-two-master\tess-two
The problem starts when I run that command because I cannot run android command from terminal. So I found solution from Stack Overflow. I needed to set ANDROID_HOME and environments variable under PATH. Then I tested "android" command and it is working.
Then I run this command again
android update project --path C:\tess-two-master\tess-two
This time, it is giving me this error
How can I solve this error? Why my update command is not working? What is wrong with my code? I am using Windows 64 OS.
This is another way. Installing using Grandle
I tried another way to install tess-two. I installed using Gradle like this according to documentation. But I cannot access to TessDataManager because it cannot be found in project.
Gradle
dependencies {
compile 'com.rmtheis:tess-two:6.0.2'
}
This is error
As you can see, I cannot access to TessDataManager class. How can I import that class?
The tess-two project has been updated to include a pre-compliled AAR that can be incorporated into your app by editing your app's build.gradle file.
This means that you can skip the steps of importing/compiling the library yourself, and follow the usage instructions on the tess-two project. After following the usage instructions, you'll be able to refer to the tess-two classes -- including the TessBaseAPI class -- directly from your project.

Updating an Android project via CLI to include two downloaded SDK libraries

I am attempting to add a main expansion file to my Cordova Android project. Before I can go further, I need to link up two libraries with the project. I am stuck on the following instructions in http://developer.android.com/google/play/expansion-files.html#AboutLibraries:
from a command line, update your project to include the libraries:
Change directories to the /tools/ directory.
Execute android update project with the --library option to add both
the LVL and the Downloader Library to your project. For example:
android update project --path ~/Android/MyApp \
--library ~/android_sdk/extras/google/market_licensing \
--library ~/android_sdk/extras/google/market_apk_expansion/downloader_library
I formatted the first part to match my system (my best understanding of what to do):
android update project --path ~/Documents/AndroidApps/apkext --library ~/Developer/android-sdk-mac_x86/extras/google/market_licensing
I got this error message:
Error: /Users/Steve/Documents/AndroidApps/apkext is not a valid project (AndroidManifest.xml not found).
I don't know how to go further. This being a Cordova app, the AndroidManifest.xml file resides in apkext/platforms/android/ and the apk build for the project is in apkext/platforms/android/ant-build
I have already successfully downloaded the two libraries asked for and they are in the tools/ folder in the path indicated. Am I applying the instructions wrong?
I think you're following instructions intended for a native android application and your project is a multiplatform cordova app.
Either you only want to focus on the android platform and don't want to use cordova CLI anymore (so you'll have to install plugins manually or using plugman) or you want to use the CLI and continue with the cordova project.
In the first case, just focus on the paltforms/adroid part of the project and forget all the rest.
paltforms/adroid contains the android native app.
So for example use
android update project --path ~/Documents/AndroidApps/apkext/platforms/android --library ~/Developer/android-sdk-mac_x86/extras/google/market_licensing
should work better.
In the other case, if you want to keep using the cordova cli, you should build a cordova plugin that would be composed of your libraries, a java class and javascript to call the native code from your cordova app. In that case you just have to configure the plugin to put the libraries in the libs folder.
Anyway, even if you're only interested in android, I think you will have to make a plugin if you want to do something with your libraries?

NDK Automatic build in eclipse OSX Invoking autoreconf in build directory:

this time with a droid related question.
Im running Eclipse Helios and Mac OS X 10.6.8
I have been following a book and a few tutorials on building the NDK from both command line and Eclipse.
I am copying the source over there is no static library business. I can compile from the command line fine with the "ndk-build" executable and it works fine.
Though i need to compile inside Eclipse for the reasons i don't need to go into here.
Ive tried 2 techniques and the one i have seen working is to convert my Project to a c++ project and then in Project / Properties / c/c++ Build tab / Build Command i set to ndk-build , this is set to be visible in my path (hence why it compiles when i go to directory and use ndk-build from Terminal)
I then in the C/C++ General tab add the following locations as include directories :
/Users/Me/Code/Android/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/include
/Users/me/Code/Android/android-ndk-r7b/platforms/android-9/arch-arm/usr/include
/Users/me/Code/Android/android-ndk-r7b/sources/android/native_app_glue
Then when i go to compile i don't get any out put i just get the following error:
Invoking autoreconf in build directory: /Users/me/Code/Android/DroidBlaster
sh -c autoreconf -i
autoreconf: `configure.ac' or `configure.in' is required
Configuration failed with error
Ive tried a few other tutorials but to no avail, if i could award a bounty on this is would as its urgent i get this fixed.
Cheers community :)
NOTE:
Ive worked out that it is using auto tools to build the project where this is incorrect as i should be building with the NDK , getting closer to an answer hopefully. Seems that i cant convert my Android project with CDT to a custom build configuration, might be a bug to do with Eclipse, trying a fresh install
Ok so i worked it out, it was because i was trying to compile using Auto tools when i should have set up the project when i should have been using "Convert to C/C++ project" didn't help though that eclipse installed CDT incorrectly and i had to reinstall to get the right plugins.

How do I build an Android project using Ant? (IntelliJ IDE)

I've a project in the IntelliJ IDEA IDE and I want to set up a parallel, production Ant build process that I can extend over time.
I have used IntelliJ's feature to create an Ant build file, and it is on the Build menu, so the Ant build process is running, and working within the IDE. All good.
But the Ant script IntelliJ has created is only compiling to class files, and is not doing a full Android build process through to an APK (as far as I can tell).
Can you point me towards a reference source (or an example) to help me understand how to get an ANT script doing a full build of an Android project?
If you know, would also be v useful to know how to then extend it to include Proguard, production signing, and inserting the production Maps key :)
Use this as a starting point:
http://developer.android.com/guide/developing/other-ide.html
I don't know IntelliJ but I shoudn't be very hard to create an ant file with the most frequent commands you need.
UPDATE:
run the following command:
android create project --target 8 --name "MyFirstProject" --path /path/to/project --activity StartingActivity --package net.sample.package
This will create a project structure. This includes a build.xml file that contains targets to build the project.
To build the application, in the root folder (/path/to/project/) run:
ant debug
It should compile your application.
You may have to install or configure ant before this works correctly but you should be able to figure it out by yourself! :)
(All the info is in the link I posted earlier)
It's pretty well described in SDK documentation. Just 3 steps to make it work:
Assuming you have been developing your activity for a while with such powerful thing as IntelliJ Idea. So as Ollie mentioned in comment you don't have to create android project from scratch. Run in command line:
android update project --path "Path to your project" --target "android-X"
where X is API level
After step one build.xml was created automatically. Now you open IntelliJ, go to ant build panel and add that build.xml.
The important step is to open properties of created task and add debug OR release to command line at execution tab.
Now you can run target and enjoy the result. It will take some more efforts to compile into signed release.
Note: your existing project structure should match to android project. Please review documentation. E.g. I had external library put in "lib" subfolder and I managed it to work only after renaming "lib" to "libs"

Categories

Resources