Android NDK: How do I rebuild the .APK file(s)? - android-studio

I'm building my NDK project on a Mac from the command line (Terminal). I am able to compile and link my "libmain" and I have been using Android Studio to install the built app on my phone.. or at least so I thought..
From what I can see, my .apk file is not changing at all when I run ndk-build.
That would mean that the same broken application is being installed on my phone over and over again even though I'm recompiling my source..
MacbookPro:android-TT admin$ find . -name "*.apk"
./app/build/outputs/apk/app-debug-unaligned.apk
./app/build/outputs/apk/app-debug.apk
The timestamps for the above .apk files never change when I do an ndk-build. I guess Android Studio must be responsible for building these?
Can ndk-build be used to create the .apk file(s) or should I be calling another utility to generate the .apk file(s) ?
I would have thought that Android Studio would have detected change in my libmain output and rebuilt the .apk file(s) but I could be wrong.

cd .. (to folder with AndroidManifest.xml)
android update project --name app --path . --target "android-14"
ant -v debug

Related

Flutter in Android Studio: Build Bundle/APK greyed out

I installed Flutter and Android Studio following this link here:
https://flutter.dev/docs/get-started/editor
I've been coding in flutter for two months now and can run my app in simulator or on a connected device no problem.
But when I try to actually build an apk via "Build" --> "Build Bundle(s) / APK", this option is greyed out.
Android Studio: 3.3.2
You can't build apk using Build option in Android Studio if you are running your Flutter project.
There are 2 solutions to build it.
In terminal, write flutter build apk (this will build apk for release version not the debug version)
Open your module in Android Studio and you can use Build option of the Android studio to build the debug apk.
For option 2, you can go to build.gradle file and you should see an option in Android Studio asking you to open the module separately (see the screenshot) Tap on this option and you can then build your apk in both debug and release mode.
I realize this might have already been answered, but I have another solution to this issue. I was having the same problem after modifying my pubspec.yaml file, so after trying to build within terminal nothing would happen. Apparently, you have to open the .yaml file within Android Studio from your project directory in order to for AS to realize that there's been a change to the file. After I opened the file from the project folder, the option for Build > flutter > Build Bundle(s) /APK > Build App Bundle finally reappeared again. Just sharing my experience and hope it can help someone else who may come across this rather strange issue.
Reopen the project from your projects directory, not from recent projects option. This solved for me
Please follow these steps:-
Go To Project Structure>Project>NOSDK
Change NOSDK to the latest
ANDROID API PLATFORM
Then go to MODULE and DO THE SAME

Android studio fails to find cmake

Due to disk space limits I moved my android SDK to a new drive/location.
I can no longer clean the project as android studio fails to locate cmake because it's looking in the old directory.
I updated the sdk path and most things work, I can even build the project and external ndk files.
But build->clean Project in android studio 3.3.2 can't find cmake when trying to clean because it's looking in the old sdk directory for cmake.
I've completely reinstalled the sdk and android studio from scratch, but it still looks in the old directory on the wrong drive when trying to execute:
task ':app:externalNativeBuildCleanDebug'
Where is this compiler location setting or script or path? and how do I change it to look in the right directory?
I used a grep tool to look for the old directory. They were mostly contained in the .externalNativeBuild directory -- I tried deleting the directory and letting android studio rebuild it, and that managed to clear whatever temp files were holding onto the old sdk directory. It seems to work now.

Location of gradle binary on Android Studio Install (Linux)

Where does a standard Android Studio install under linux place the gradle executable?
I want to run it from the cmd line, but can't find it to add to my PATH
By default Android Studio uses a Gradle wrapper. You can find the gradlew file in the project root. Check this link
If you want you can install your own Gradle version and use it by command line. In that case you can tell Android Studio to use that version instead of the wrapper

Open cocos2d-x-3.7 in Android Studio

What is the proper way to open cocos2d-x-3.7 in Android Studio?
I tried:
Open existing project in Android Studio project > Choose proj.android-studio directory (In another attempt, I also tried to choose the base directory MyGame)
Run
Error: couldn't find "libcocos2dcpp.so.
Moreover, it also does Classes directory in the Project.
Android Studio is only partially supported in cocos2d-x 3.7 and 3.8. With the default project you will only be able to run your app without debugging using Android Studio.
Prior to running your app in Android Studio you will have to compile using the Android Studio flag:
cocos compile -p android --android-studio
You will have to run this command after any changes to your app are made, since the default Android Studio currently doesn't compile your project.
Furthermore the default Android Studio project does not include the Classes directory.
Suggestion: Use Eclipse or Xcode to develop your cocos2d-x projects for now. Hopefully future versions of cocos2d-x will have better support for Android Studio out of the box, this is critical considering Google is dropping support for Eclipse.
When you try to run the application on Android Studio, you get the error couldn't find "libcocos2dcpp.so" because it doesn't have the NDK for building your game.
I recommend you to compile proj.android and import that, cocos2d-x 3.7 doesn't support full Android Studio yet. Do this:
cocos compile -p android
Then import your proj.android to Android Studio.
Now you can run your application but you won't able to debug it, bad news (it will just install the APK on your device or virtual device).
Hope it helps.
Error: couldn't find "libcocos2dcpp.so.
For this you need to compile android studio project first so .so files and classes folder will be generated.
Open your command line and enter the following command to compile your android studio project:
cocos compile -p android --android-studio --ap android-24 --app-abi x86
This will create required files in your proj.android-studio directory.
Now import this project into Android Studio and try to run it.

building hello-jni sample in Android NDK causes error "Default target help does not exist in this project"

Trying to build hello-jni sample in Android NDK.
Followed instructions per
http://developer.android.com/sdk/ndk/overview.html#samples to create build .xml,
android update project -p . -s
Trying to run under Eclipse Helios SR2. I get this error:
Description Resource Path Location Type
Default target help does not exist in
this project build.xml /HelloJni line
2 Ant Buildfile Problem
in build.xml,
<project name="HelloJni" default="help">
any suggestions appreciated.
Suppose your install paths of sdk and ndk are
~/android-sdk-mac_x86/ and ~/android-ndk-r5c
If you don't use Eclipse and use ant
export PATH=${PATH}:~/android-sdk-mac_x86/tools:~/android-ndk-r5c
cd ~/android-ndk-r5c/samples/hello-jni
ndk-build
Assume target 1 is the project target
android update project -t 1 -p ~/android-ndk-r5c/samples/hello-jni
or simply
android update project -t 1 -p .
Debug build
ant debug
Emulator started or device connected
ant install

Resources