Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples to match new build system #10

Open
FlorianUekermann opened this issue Aug 15, 2017 · 4 comments
Open

Update examples to match new build system #10

FlorianUekermann opened this issue Aug 15, 2017 · 4 comments

Comments

@FlorianUekermann
Copy link
Contributor

The new build system (the gradle stuff) is actually relatively nice (although it took me a whole day to figure out all of the details) and removes the need for the android tool.

I don't have time to update the examples right now and would also like to reduce some of the ridiculous boilerplate before that. I'll just document the most interesting ingredients here for later/others. I'll have more time in a couple of weeks.
It may be possible to shorten this a bit, but this is the conventional setup. The root (build) folder should contain these files for packing a .so into an apk with a native activity:

/build.gradle - top level build file (boilerplate)
/setting.gradle - this where the actual build file is includes (boilerplate)
/gradlew (boilerplate to make this work on independent of systems gradle version)
/gradle (boilerplate to make this work on independent of systems gradle version)
/app/build.gradle - actual build file
/app/src/main/AndroidManifest.xml
/app/src/main/jniLibs/armeabi-v7a/libexample.so - put the compiled go library here
/app/src/main/assets - put assets here

Running gradle(w) build will produce an apk.

build.gradle

buildscript {
    repositories {
       jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

/settings.gradle

include ':app'

/app/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion = 24
    buildToolsVersion = '25.0.0'

    defaultConfig {
        applicationId = 'com.example.native_activity'
        minSdkVersion 24
        targetSdkVersion  24
        ndk {
            abiFilters 'armeabi-v7a'
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            jniDebuggable true
        }
    }
}
@xlab
Copy link
Owner

xlab commented Aug 15, 2017

This is an amazing contribution, dude!
The build process haunted me for so long, especially in the light of recent NDK updates..

I will try to find hours as well to re-organise all examples. They are mostly boiler-plate all along.

@FlorianUekermann
Copy link
Contributor Author

FlorianUekermann commented Aug 15, 2017

The build process haunted me for so long, especially in the light of recent NDK updates..

Yep :-), me too, coming up with this was not fun. I wish the official docs were better for the "I can compile on my own, just make an apk already" case.

@xlab
Copy link
Owner

xlab commented Oct 3, 2017

Reopening as examples need some care from me.

@xlab xlab reopened this Oct 3, 2017
@atlazar
Copy link
Contributor

atlazar commented Oct 29, 2017

I'm updating example-egl to gradle here. I switch to Gradle build system as a entry point (because currently this is default Android build system). Currently first version works and I was able to build and deploy example-egl by single command: gradle installDebug

I'm planning to improve multi-arch support (arm and x86 for example) and refactor my .sh scripts. After what I'll open PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants