android studio 2.1 issue with NDK - android-ndk

I am trying to use AndEngine with Android Studio 2.1 and I am running issues specifically with the NDK stuff. The version of AndEngine I am trying to use is the GLES2-AnchorCenter for reference. I create my project and add AndEngine as a module, then give my project a dependency on my AndEngine module. What I end up with is an issue with native code, specifically in in GLES20Fix.c. I get an error message about openGL ES2.0 specific stuff:
Error:(8) undefined reference to `glVertexAttribPointer'
Error:(12) undefined reference to `glDrawElements'`
I know this topic has come up before and I have read this article on the subject but that's what I was already trying to follow and that uses an older version of Android Studio that has a different import option I do not have in 2.1. I have also checked and the NDK plugin for android studio is installed and my minimum build target is over SDK level 9.
One strange detail: when I tried importing andengine as a library in eclipse it worked okay. I don't want to rely on that because I know eclipse is no longer supported for android developer tools so I want to switch off it to the newest version of Android Studio.

Can you try adding
ldLibs.addAll(['EGL', 'GLESv2'])
eg. https://github.com/googlesamples/android-ndk/blob/master/Teapot/app/build.gradle

I had the same issue. This answer helped me.
I just needed to add the following to build.gradle:
sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDir 'libs'
}
}
and then rebuild the project.

Related

How to configure an iOS Application for Kotlin Multiplatform in Android Studio?

I want to add a Run/Debug Configuration for an iOS Application for a Kotlin Multiplatform Mobile application in Android Studio 4.1.2. However, there seems to be a problem with the configuration for iOS.
In the screenshot below you can see the problem. In the dialog "Run/Debug Configuration" Android Studio complains about
Error: Please specify Xcode project location in xcodeproj property of gradle.properties
Using the "Fix" button does not solve the problem. Android Studio just adds an additional xcodeproj to gradle.properties and the complains about a duplicate parameter.
I also tried different paths (relative and absolute) for xcodeproj. No luck.
If I remember correctly, it used to work out of the box. A new Kotlin Multiplatform Mobile project was automatically configured for Android and iOS. I'm not sure what changed. Probably something was updated.
Is this a bug with the KMM plugin? Or is there something I can do on my system to fix this?
don't do that with Android Studio.
Just open Xcode, click on 'open another project...', locate to the iosApp folder that named it when creating your project on Android Studio.
after that, just click run and have fun.
If the project doesn't run right away even on opening it from Xcode and shows the shared framework is missing, Then try generating the shared framework for iOS platform using terminal. Navigate to the project folder and execute
Command: ./gradlew packForXcode
Now the shared framework should have a xcode-frameworks product and you should be able to build and run the project through Xcode.
I fixed it by downgrading the Kotlin version from 1.4.30 to 1.4.21. You can check this thread here. To downgrade, download the version you want from the plugin store and choose the install plugin from disk as in the picture below
Upgrading Android Studio version to 4.2.1, KMM plugin version to 0.2.6, creating new KMM project with KMM plugin, the problem can be fixed automatically.
If you don't wanna use Xcode:
Look like there is some IDE issues in this versions, one option would be to downgrade the Kotlin version.
What worked for me was to download the latest Canary Android Studio and setup my KMM project there.
Hopefully soon this will be stable for the next versions
Same as here: https://stackoverflow.com/a/66941077/3117650
Look like there is some IDE issues in this versions, one option would be to downgrade the Kotlin version.
What worked for me was to download the latest Canary Android Studio and setup my KMM project there.
Hopefully soon this will be stable for the next versions

Creating a project with a previous version of gradle in android studio

I am currently learning android with a book called head first android 2nd edition.
As a reference I am using the code uploaded by the writer to github.
I am currently using the latest andriod studio 3.1 which comes with the latest version of gradle.
When I checked out the source code, I discovered that the version of gradle being used is a previous version.
Now my problem is that while practicing on my own, I wanted to create a new project with the same version of gradle, which the head first android writer provided.
How can I achieve that ?
PS: my android studio runs faster with the gradle version which the writer provided in his source code.
There already was a question here where you get explained how to change the gradle version, you are using. It's very simple. Just read this thread.

Does Android Studio support Code completion for C/C++?

The code completion is fine on Android Studio java project. But I want to use Android Studio to edit some existing C file(.cpp).
for example, if i have declared some function, then i type the function in other section. But the android studio doesn't show up the code suggestion or some debugging.
Can Android Studio support Code completion for C/C++ like this:?
Yes it does, as long as the project is setup to use the NDK and the C/CPP sources are included in the project.
Try pulling the ndk sample repo and try opening one of the projects.
If you have a java project and want to edit some arbitrary C or C++ source, then no. It does not have enough information about the source file, include paths, compiler etc...
If your project uses Android.mk to build, it will be a bug of Android Studio. I have been reported.
Android.mk project cannot show code completion for cpp.
It seems that old version of Android Studio does not support code completion of jni native build (with Android.mk as configuration file), and that should already be fixed now.
But if you are using CMake in your project as external building tool and code completion still does not work, It's probably because you have more than one version of cmake installed. You can try to remove extra ones from SDK manager and restart Android Studio, it should work.
To see installed CMake version, you can open the SDK manager and check the 'show package details' on the right bottom. You can view cmake tools installed with different versions.

Android studio 1.4 Library module with JNI

I'm trying to create an android module with JNI in android studio, but all the documentation I found is for older versions of android studio that did not officially support JNI. So, what is the correct way to create Library module with JNI in Android studio 1.4?
It is exactly same as with 'com.android.model.application'. Everything seems to work fine except that for me, native debugging required running NDK build steps in the app module.

Android studio doesn't create project structure

I am new to Android studio. I tried to create my first project and there is no project structure only gradle files. What am I doing wrong? I keep getting these files with creation of another new project.
Update SDK via Android SDK Manager. You need all packages in Tools to be installed.
But even after doing so, I can't make it to auto generate resources. So I continue to deal with it...
I found what was my problem. I updated Android studio from version 1.x to 2.x. On official site is written that if you try to install version 2.x into same location Android studio might not work properly and there could be some unexpected behavior.
So just removing Android studio and then reinstaling it, worked perfectly.

Resources