1

for several weeks i learn how to compile IBR-DTN source from IBR-DTN Github , and now im being stuck at Android NDK stuff. here my failure log on Android Studio, i tried Windows version and Linux version there are always same error

Error:Execution failed for task ':app:ndkBuild'. 
> A problem occurred starting process 'command 'sh''

and this is my build.gradle

    apply plugin: 'android-sdk-manager'
    apply plugin: 'com.android.application'

def createVersionName() {
    if (System.getenv().containsKey("BUILD_NUMBER")) {
        if (System.getenv().containsKey("GIT_COMMIT")) {
            return rootProject.ext.versionName + "-" + System.getenv("GIT_COMMIT").substring(0, 7)
        } else {
            return rootProject.ext.versionName + "-" + System.getenv("BUILD_NUMBER")
        }
    } else {
        return rootProject.ext.versionName
    }
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "de.tubs.ibr.dtn"
        minSdkVersion 9
        targetSdkVersion 22
        versionCode System.getenv("BUILD_NUMBER") as Integer ?: rootProject.ext.versionCode
        versionName createVersionName()
    }
    signingConfigs {
        release {
            storeFile file(System.getenv("KEYSTORE") ?: "publish.keystore")
            storePassword System.getenv("KEYSTORE_PASSWD")
            keyAlias System.getenv("KEY_ALIAS") ?: android.defaultConfig.applicationId
            keyPassword System.getenv("KEY_PASSWD")
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets.main {
        jniLibs.srcDir 'src/main/libs'
        jni.srcDirs = []
    }
}

// enable signing if the keystore exists
if (android.signingConfigs.release.storeFile.exists()) {
    android.buildTypes.release.signingConfig = android.signingConfigs.release
}

task ndkBuild(type: Exec) {
    executable "sh"
    workingDir "src/main/jni"
    args "build.sh"
}
preBuild.dependsOn ndkBuild

dependencies {
    compile 'de.tubs.ibr.dtn:library:1.1.2'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.jjoe64:graphview:3.1.+'
    compile 'com.google.zxing:core:3.2.+'
    compile 'com.google.zxing:android-integration:3.2.+'
}

Here is the error log from Android Studio: Here is the error log from Android Studio

Looking for help to finish my thesis, i appreciate every single advice here. MUCH LOVE XOXO

Community
  • 1
  • 1

4 Answers4

1

I haven't seen this syntax for defining a Gradle exec task before.

task ndkBuild(type: Exec) {
    executable "sh"
    workingDir "src/main/jni"
    args "build.sh"
}

I would define it like this instead, per the Gradle docs:

task ndkBuild(type: Exec) {
    if (isWindows()) {
        commandLine 'cmd', '/c', 'src/main/jni/build.bat'
    }
    else {
        commandLine 'src/main/jni/build.sh'
    }
}
Francesca Nannizzi
  • 1,695
  • 13
  • 18
  • The syntax is really a bit is uncommon, but in fact both versions are working fine. – MW. Oct 02 '16 at 10:44
0

I was fighting against the same problem (also with IBR DTN). I could fix the problem by adding the NDK-path to the PATH variable inside the src/main/jni/build.sh script.

#!/bin/sh
PATH=/…/android-sdk/ndk-bundle/:$PATH
export PATH
…

And this link might also be helpful:

https://github.com/ibrdtn/ibrdtn/wiki/Build-IBR-DTN-for-Android

MW.
  • 544
  • 5
  • 19
0

Well for starter I would suggest you use exactly the same ndk version against which they tested. ndk. Download and extract it and then simply change variable path directly in src/main/jni/build.sh. Then run the script it will build it and lastly run ./gradlew. I have tested it again and again, it works only on Linux. I used mac but there were some scary errors. I am also doing thesis on it

Abubakar
  • 1,022
  • 10
  • 20
-1

I think that your application need ROOT permission.

  • 1
    This is a problem during the build process of the app. It has nothing to do with root-access on the phone. – MW. Oct 02 '16 at 10:42