Updated Android project files and documentation

This commit is contained in:
Sam Lantinga 2018-10-28 10:31:06 -07:00
parent 14c55ac890
commit e381a1599d
6 changed files with 19 additions and 40 deletions

View File

@ -9,7 +9,6 @@ else {
android { android {
compileSdkVersion 26 compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig { defaultConfig {
if (buildAsApplication) { if (buildAsApplication) {
applicationId "org.libsdl.app" applicationId "org.libsdl.app"
@ -21,10 +20,9 @@ android {
externalNativeBuild { externalNativeBuild {
ndkBuild { ndkBuild {
arguments "APP_PLATFORM=android-14" arguments "APP_PLATFORM=android-14"
abiFilters 'armeabi-v7a', 'x86' abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
} }
} }
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
release { release {
@ -61,9 +59,5 @@ android {
} }
dependencies { dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
} }

View File

@ -1,7 +1,8 @@
# Uncomment this if you're using STL in your project # Uncomment this if you're using STL in your project
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information # You can find more information here:
# APP_STL := stlport_static # https://developer.android.com/ndk/guides/cpp-support
# APP_STL := c++_shared
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 APP_ABI := armeabi-v7a arm64-v8a x86 x86_64

View File

@ -8,9 +8,6 @@
android:versionName="1.0" android:versionName="1.0"
android:installLocation="auto"> android:installLocation="auto">
<!-- Android 4.0.1 -->
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16" />
<!-- OpenGL ES 2.0 --> <!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" /> <uses-feature android:glEsVersion="0x00020000" />

View File

@ -3,9 +3,10 @@
buildscript { buildscript {
repositories { repositories {
jcenter() jcenter()
google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
@ -15,6 +16,7 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
jcenter() jcenter()
google()
} }
} }

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

View File

@ -77,18 +77,16 @@ For more complex projects, follow these instructions:
and rename it to the name of your project. and rename it to the name of your project.
2. Move or symlink this SDL directory into the "<project>/app/jni" directory 2. Move or symlink this SDL directory into the "<project>/app/jni" directory
3. Edit "<project>/app/jni/src/Android.mk" to include your source files 3. Edit "<project>/app/jni/src/Android.mk" to include your source files
4. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
If you want to use Android Studio (recommended), skip to the Android Studio section below. 4a. If you want to use Android Studio, simply open your <project> directory and start building.
5. Run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device 4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
Here's an explanation of the files in the Android project, so you can customize them: Here's an explanation of the files in the Android project, so you can customize them:
android-project/app android-project/app
build.gradle - build info including the application version and SDK build.gradle - build info including the application version and SDK
src/main/AndroidManifest.xml - package manifest. Among others, it contains the class name src/main/AndroidManifest.xml - package manifest. Among others, it contains the class name of the main Activity and the package name of the application.
of the main Activity and the package name of the application.
jni/ - directory holding native code jni/ - directory holding native code
jni/Application.mk - Application JNI settings, including target platform and STL library jni/Application.mk - Application JNI settings, including target platform and STL library
jni/Android.mk - Android makefile that can call recursively the Android.mk files in all subdirectories jni/Android.mk - Android makefile that can call recursively the Android.mk files in all subdirectories
@ -216,26 +214,10 @@ detach it.
You can use STL in your project by creating an Application.mk file in the jni You can use STL in your project by creating an Application.mk file in the jni
folder and adding the following line: folder and adding the following line:
APP_STL := stlport_static APP_STL := c++_shared
For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation. For more information go here:
https://developer.android.com/ndk/guides/cpp-support
================================================================================
Additional documentation
================================================================================
The documentation in the NDK docs directory is very helpful in understanding the
build process and how to work with native code on the Android platform.
The best place to start is with docs/OVERVIEW.TXT
================================================================================
Using Android Studio
================================================================================
You can open your project directory with Android Studio and run it normally.
================================================================================ ================================================================================
@ -291,7 +273,10 @@ You can see the complete command line that ndk-build is using by passing V=1 on
ndk-build V=1 ndk-build V=1
If your application crashes in native code, you can use addr2line to convert the If your application crashes in native code, you can use ndk-stack to get a symbolic stack trace:
https://developer.android.com/ndk/guides/ndk-stack
If you want to go through the process manually, you can use addr2line to convert the
addresses in the stack trace to lines in your code. addresses in the stack trace to lines in your code.
For example, if your crash looks like this: For example, if your crash looks like this: