Can't build Tango c examples - android

I downloading the Tango C examples and opened point-cloud-jni-example in Android Studio. I have ndk installed and added ndk.dir=E:\Android\sdk\ndk-bundle to my local.properties file. Gradle syncs without errors, but when I run, I get this error:
Error:Execution failed for task ':app:ndkBuild'.
A problem occurred starting process 'command 'E:\Android\sdk\ndk-bundle/ndk-build''
I get the same error with motion-tracking-jni-example and hello-tango-jni-example and I assume the others as well.
What am I doing wrong?
build.gradle (app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.projecttango.experiments.nativepointcloud"
minSdkVersion 19
targetSdkVersion 19
}
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [];
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
task ndkBuild(type: Exec) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkbuild = properties.getProperty('ndk.dir', null)+"/ndk-build"
commandLine ndkbuild, '-C', file('src/main/jni').absolutePath
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
build.gradle (Project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
My system:
Windows 8.1 64 bit
Android Studio 1.3 (AI-141.2117773)
NDK r10e extracted to E:\Android\sdk\ndk-bundle
Device: Project Tango Tablet with Schur core

You need to append '.cmd' to the ndkbuild command. By that, I mean that the line
def ndkbuild = properties.getProperty('ndk.dir', null)+"/ndk-build"
should read
def ndkbuild = properties.getProperty('ndk.dir', null)+"/ndk-build.cmd"
It was no fault of your own, I noticed the same issue when I went to compile on my Surface.

Related

Flutter Android Build Failed : com.android.tools.r8.CompilationFailedException: Compilation failed to complete

Been trying for days; googling and trying all sorts of 'fixes' and 'dependencies' etc but still not able to build APK for release. Debug is ok.
My command: flutter build apk --release
error:
AILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithR8ForRelease'.
com.android.tools.r8.CompilationFailedException: Compilation failed to complete
BUILD FAILED in 2m 1s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 147.3s (!)
[!] The shrinker may have failed to optimize the Java bytecode.
To disable the shrinker, pass the --no-shrink flag to this command.
To learn more, see: https://developer.android.com/studio/build/shrink-code
Gradle task assembleRelease failed with exit code 1
build.grade (app):
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
throw new GradleException("versionCode not found. Define flutter.versionCode in the local.properties file.")
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'4
throw new GradleException("versionName not found. Define flutter.versionName in the local.properties file.")
}
apply plugin: 'com.android.application'
// 20/2/20
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
// 20/2/20
apply plugin: 'com.google.gms.google-services'
// Add the Fabric plugin. 10 March 2020
apply plugin: 'io.fabric'
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
def kotlin_version = '1.3.21'
android {
compileSdkVersion 28
// 20/2/20
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "net.hotsource.peribuddy"
minSdkVersion 24
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
//testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// Enabling multidex support.
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
minifyEnabled true
//shrinkResources true
//useProguard true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
}
debug {
// minifyEnabled true
}
}
}
flutter {
source '../..'
}
dependencies {
// 28 May 2019
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0' // 1.0.2
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
implementation 'com.android.support:multidex:1.0.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
// 10 March 2020
// (Recommended) Add the Google Analytics dependency.
implementation 'com.google.firebase:firebase-analytics:17.4.2' // 17.2.3
// Add the Firebase Crashlytics dependency.
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.google.firebase:firebase-messaging:20.2.0'
implementation "com.android.support:support-v4:28.0.0"
implementation "com.android.support:support-fragment:28.0.0"
implementation 'com.google.firebase:firebase-firestore:21.4.3'
implementation 'com.google.firebase:firebase-firestore-ktx:21.4.3'
}
// firebase_crashlytics
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
build.gradle (project):
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
// For Crashlytics SDK
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools:r8:1.6.84' // Must be before the Gradle Plugin for Android.
classpath 'com.android.tools.build:gradle:3.4.2' // 3.1.2 3.3.0-alpha13 4.10.2 330 3.3.2 3.6.3
// classpath 'com.google.gms:google-services:4.2.0' // 3.2.1 4.0.1 4.1.0 4.3.3
classpath 'com.google.gms:google-services:4.2.0'
// Add the Fabric Crashlytics plugin. 10 march 2020 1.31.2
classpath 'io.fabric.tools:gradle:1.31.2'
//classpath 'io.fabric.tools:gradle:1.+' // new
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Add fabric classpath
//classpath 'io.fabric.tools:gradle:1.26.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
configurations.matching { it.name == '_internal_aapt2_binary' }.all { config ->
config.resolutionStrategy.eachDependency { details ->
details.useVersion("3.5.0-alpha03-5252756")
}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
the problem, in Android studio related with jdk version. you can go through project structure and change Gradle's jdk. wish it will solve.
In My case,
after i run with -verbose
flutter build apk -v
"MainActivity is defined multiple times"
after removed one of that apk build successful.
MainActivity found in both kotin & java subfolder in android folder
this happens when i add external plugin
face the similar issue. what I did is just disable R8.
as in your terminal :
flutter build apk --no-shrink
or in your app level build.gradle:
minifyEnabled false
shrinkResources false
then build apk as normal
by the way, my apk works without R8, because I don't know how to stop it deleting my files

Gradle settings for this project are not configured yet - android studio

I'm trying to load an existing project and i'm running into these problems:
clicking ok i will have this:
Searching here I have not found grangle 2.2.2. Minimum grandle is 3.0.0
build.grandle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
app.build.grande:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.prouast.heartbeat"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
// add a task that calls regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build",
'-C', file('src/main/jni').absolutePath, // relative path to jni source
'NDK_LIBS_OUT=../jniLibs',
'-j', Runtime.runtime.availableProcessors(),
'all',
'NDK_DEBUG=1'
}
task ndkClean(type: Exec, description: 'Clean JNI object files') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build",
'-C', file('src/main/jni').absolutePath, // relative path to jni source
'NDK_LIBS_OUT=../jniLibs',
'clean'
}
// add this task as a dependency of Java compilation
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(['ndkBuild'])
}
clean.dependsOn(['ndkClean'])
sourceSets.main {
jni.srcDirs = []
//jniLibs.srcDir 'src/main/libs'
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':libraries:opencv')
}
Need I to change something on app grandle or anybody have some suggestion?
Could you suggest me some links to follow or explain step by step how can I solve it?
EDIT :
adding the jcenter to gradle.build resolves the issue:
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
Click Ok for gradle wrapper or go manually at build.gradle and update the following line :
**classpath 'com.android.tools.build:gradle:3.2.1'**
Just click OK for Studio to automatically perform the Gradle configuration.

Android project there is no output dir after gradle build success?

I am learning Gradle for Android recently. For learning impressively, i create all android application files manually.
my project dirs as below
package name : com.wonbin.gradledemo
project build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
allprojects {
repositories {
jcenter()
}
}
app module build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.wonbin.gradledemo"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "adroid.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
lintOptions {
htmlReport true
htmlOutput file("lint-results.html")
}
}
dependencies {
compile fileTree(dir:'libs',include:['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',{
exclude group: 'com.android.support',module: 'support-annotations'})
compile 'com.android.support:appcompat-v7:23.4.0'
testCompile 'junit:junit:4.12'
}
./gradlew build is successful and there are 'intermediates' and 'generated'
dirs , but no outputs dir, i don't know what to do!
Thanks a lot!
You need not only to build, but to assemble it as well.
To do this you can run a gradle task
assembleDebug
Or use Build -> Build APK main menu item

Superpowered SDK: Error:Execution failed for task ':app:ndkBuild'. A dikkat occurred starting process 'command 'null/ndk-build''

I am trying to install Superpowered example app on my phone using Android Studio but it's not getting built. It shows an error:
Error:Execution failed for task ':app:ndkBuild'.
> A problem occurred starting process 'command 'null/ndk-build''
build.gradle code is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.superpowered.hlsexample"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = []
}
}
task ndkBuild(type: Exec) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')
commandLine "$ndkDir/ndk-build", '-B', '-C', file('src/main/jni').absolutePath
// Windows users: commandLine "$ndkDir\\ndk-build.cmd", '-B', '-C', file('src/main/jni').absolutePath
}
lintOptions {
abortOnError false
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
}
Please help me find the right solution. And/Or guide me on how to add NDK to the current app. Thanks in Advance.
Just had same problem. Solved it by entering "File -> Project Structure". For my case "Android NDK location" was empty as shown. Clicking "Select" fixed it.
Open local.properties. Set ndk.dir to your ndk folder.
Just add
ndk.dir=
with you ndk folder in local.properties

SIPdroid Android Studio ndk integration error

I'm currently using Android Studio 2.0 preview 4. I have followed the guide from tools.android.com and tested NDK samples from github. The samples worked without a hitch, but when I implemented it on the SIPdroid project, it throws this error when I rebuild the project:
Error:(78, 1) A problem occurred configuring project ':app'.
Exception thrown while executing model rule: model.android
Cannot set readonly property: minSdkVersion for class: com.android.build.gradle.managed.ProductFlavor_Impl
when I try to use gradle project sync it gives this error:
Error:Unable to load class 'com.android.build.gradle.managed.ProductFlavor_Impl'.
Possible causes for this unexpected error include:You are using JDK version 'java version "1.7.0_79"'. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle.
Please update to a newer version (e.g. 1.7.0_67).
Open JDK SettingsGradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Android project structure now looks like this. previously the jni folder is separated from the java folder.
Here's my config:
SIPdroid/app/build.gradle
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "com.test.sipdroid"
minSdkVersion = 15
targetSdkVersion = 23
versionCode = 1
versionName = "1.0"
}
}
compileOptions.with {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
/*
* native build settings
*/
android.ndk {
moduleName = "SIPdroid"
/*
* Other ndk flags configurable here are
* cppFlags.add("-fno-rtti")
* cppFlags.add("-fno-exceptions")
* ldLibs.addAll(["android", "log"])
* stl = "system"
*/
}
android.sources {
main.java {
source {
srcDir 'src'
}
}
main.jni {
source {
srcDirs = []
}
}
main.jniLibs {
source {
srcDirs = ['src/main/libs']
}
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.txt'))
}
}
android.productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" #
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
create("x86") {
ndk.abiFilters.add("x86")
}
create("x86-64") {
ndk.abiFilters.add("x86_64")
}
create("mips") {
ndk.abiFilters.add("mips")
}
create("mips-64") {
ndk.abiFilters.add("mips64")
}
// To include all cpu architectures, leaves abiFilters empty
create("all")
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
SIPdroid/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.4.0'
// classpath 'com.android.tools.build:gradle:1.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
SIPdroid/gradle-wrapper.properties
#Mon Jan 04 16:06:26 PHT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
SIPdroid/local.properties
ndk.dir=/path/Android/sdk/ndk-bundle
sdk.dir=/path/Android/sdk
I just recently solved my issue by adding this to my orignal app/build.gradle file without using the experimental gradle build ('com.android.tools.build:gradle-experimental:0.4.0') as indicated in the google samples.
This solution finally solved the issue NDKBuild Failure. This additional script builds your jni files using ndkBuild.
app/build.gradle
sourceSets.main {
jniLibs.srcDir 'src/main/libs' // use the jni .so compiled from the manual ndk-build command
jni.srcDirs = [] //disable automatic ndk-build call
}
task ndkBuild(type: Exec) {
// commandLine 'ndk-build', '-C', file('src/main/jni').absolutePath <-- Not working
commandLine '/home/user/Android/sdk/ndk-bundle/ndk-build', '-C', file('src/main/jni').absolutePath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
SIPdroid/build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
You also need to have an empty libs folder under app/src/main. My mistake was that I renamed the /jni folder to /libs. After running the build, it will compile your jni to the /libs folder to .so files
jniLibs in your Android project structure view will look like this. This is from your app/src/main/libs as indicated in your build.gradle script
I hope this helps.

Categories

Resources