How to fix NDK build error for HelloCardboard sample - android

I am trying to compile Google Cardboard Sdk sample.
I am following instructions given by google's official docs
I am stuck at step 3, where I am supposed to assemble the project:
This is the error I am getting when I start to assemble:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':hellocardboard-android:externalNativeBuildDebug'.
> Build command failed.
Error while executing process C:\Users\Shanu\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\ninja.exe with arguments {-C C:\Projects\cardboard\hellocardboard-android\.cxx\cmake\debug\x86 cardboard_jni}
ninja: Entering directory `C:\Projects\cardboard\hellocardboard-android\.cxx\cmake\debug\x86'
ninja: error: '../../../../libraries/jni/x86/libcardboard_api.so', needed by '../../../../build/intermediates/cmake/debug/obj/x86/libcardboard_jni.so', missing and no known rule to make it
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
29 actionable tasks: 2 executed, 27 up-to-date
1:55:12 PM: Task execution finished 'assemble'.
Then I tried to run with --stacktrace
Caused by: org.gradle.internal.UncheckedException: Build command failed.
But there is an additional warning:
WARNING: This app only has 32-bit [armeabi-v7a,x86] native libraries. Beginning August 1, 2019 Google Play store requires that all apps that include native libraries must provide 64-bit versions. For more information, visit https://g.co/64-bit-requirement
Well, that doesn't give me an idea, as to have never used NDK/Cardboard SDK ever before.
Here is how the build.gradle(hellocardboard) looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.google.cardboard.hellocardboard"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
externalNativeBuild {
cmake {
cppFlags "-std=gnu++11"
arguments "-DANDROID_STL=c++_shared"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
// Android Mobile Vision
implementation 'com.google.android.gms:play-services-vision:15.0.2'
//noinspection GradleCompatible
implementation 'com.android.support:design:28.0.0'
implementation project(":sdk")
}
// The dependencies for NDK builds live inside the .aar files so they need to
// be extracted before NDK targets can link against.
task extractNdk(type: Copy) {
if (file("${project.rootDir}/sdk/build/outputs/aar/sdk-release.aar").exists()) {
copy {
from zipTree("${project.rootDir}/sdk/build/outputs/aar/sdk-release.aar")
into "libraries/"
include "jni/**/libcardboard_api.so"
}
copy {
from "${project.rootDir}/sdk/include/cardboard.h"
into "libraries/"
}
}
}
task deleteNdk(type: Delete) {
delete "libraries/jni"
delete "libraries/cardboard.h"
}
build.dependsOn(extractNdk)
clean.dependsOn(deleteNdk)
Here is the whole project hosted on my GitHub
Everything is at google's default settings, and I haven't configured anything, except
Install these components from the SDK manager:
CMake
LLDB
NDK (Side by Side)
What is the issue here and how can I fix it?

This usually happens when you haven't built the SDK.
The sample app tells you to click the "assemble" option in the Gradle tab. You should click the "assemble" option under ":sdk", not the one under ":hellocardboard-android".
The official instructions are unclear about this; it is only visible if you look closely at the screenshots there.

Related

Build failed with an exception in QT/android-armv7

I cant build armv7 in qt/android. Where do I need to set in Qt or Android Studio?
This is for a Qt 5.12.2, compiler is Android for armeabi-v7a and Android Studio (sdk and ndk-bundle)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "com.smewise.camera2"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.13-beta-3'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
}
Build log:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugAidl'.
> java.io.IOException: com.android.ide.common.process.ProcessException: Error while executing process C:\Users\cansunurk\AppData\Local\Android\Sdk\build-tools\29.0.0\aidl.exe with arguments {-pC:\Users\cansunurk\AppData\Local\Android\Sdk\platforms\android-28\framework.aidl -oC:\Users\cansunurk\Documents\build-denemee-Android_for_armeabi_v7a_Clang_Qt_5_13_0_for_Android_ARMv7-Debug\android-build\build\generated\source\aidl\debug -IC:\QtCreator\5.13.0\android_armv7\src\android\java\src -IC:\Users\cansunurk\Documents\build-denemee-Android_for_armeabi_v7a_Clang_Qt_5_13_0_for_Android_ARMv7-Debug\android-build\src\debug\aidl -IC:\Users\cansunurk\Documents\build-denemee-Android_for_armeabi_v7a_Clang_Qt_5_13_0_for_Android_ARMv7-Debug\android-build\src -IC:\Users\cansunurk\Documents\build-denemee-Android_for_armeabi_v7a_Clang_Qt_5_13_0_for_Android_ARMv7-Debug\android-build\aidl -dC:\Users\CANSUN~1\AppData\Local\Temp\aidl8998818284823510668.d C:\QtCreator\5.13.0\android_armv7\src\android\java\src\org\kde\necessitas\ministro\IMinistro.aidl}
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BU?LD FAILED in 14s
3 actionable tasks: 1 executed, 2 up-to-date
Building the android package failed!
-- For more information, run this command with --verbose.
10:44:02: The process "C:\QtCreator\5.13.0\android_armv7\bin\androiddeployqt.exe" exited with code 14.
Error while building/deploying project denemee (kit: Android for armeabi-v7a (Clang Qt 5.13.0 for Android ARMv7))
When executing step "Build Android APK"
10:44:02: Elapsed time: 00:20.
I solved this problem by SDK Build-Tools. If have same problem, need follow this way,
Android Studio>Setting>Android SDK> SDK Tools(Show Package Details)> Version 29 (Unchecked)

Duplicate class definitions in gradle assemble AAR library

I am compiling my AAR library in Android Studio, in the perfect debug mode, but when the release with ProGuard, the error occurs:
My build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:3.2.0'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 23
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
version '3.10.2'
path "src/main/cpp/CMakeLists.txt"
}
}
repositories{
flatDir{
dirs 'libs'
}
/** Following lines are for accessing the TapLinx jars from Repo directly */
maven {
credentials {
username "sdkuser"
password "taplinx"
}
url "http://maven.taplinx.nxp.com/nexus/content/repositories/taplinx/"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.4.0-b180830.0359'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9'
implementation 'com.google.android.gms:play-services-analytics:15.0.2'
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation('taplinx-android:nxpnfcandroidlib:1.6#aar') {
transitive = true
changing = true
}
}
My Error Log is:
...
Reading library jar [/Users/andresflorespolicarpo/Library/Android/sdk/platforms/android-28/android.jar]
Reading library jar [/Users/andresflorespolicarpo/Library/Android/sdk/platforms/android-28/optional/org.apache.http.legacy.jar]
Reading library jar [/Users/andresflorespolicarpo/Library/Android/sdk/platforms/android-28/optional/android.test.mock.jar]
Reading library jar [/Users/andresflorespolicarpo/Library/Android/sdk/platforms/android-28/optional/android.test.base.jar]
Reading library jar [/Users/andresflorespolicarpo/Library/Android/sdk/platforms/android-28/optional/android.test.runner.jar]
Note: there were 1 duplicate class definitions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning: there were 1 classes in incorrectly named files.
You should make sure all file names correspond to their class names.
The directory hierarchies must correspond to the package hierarchies.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)
If you don't mind the mentioned classes not being written out,
you could try your luck using the '-ignorewarnings' option.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':taplinx:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 3s
40 actionable tasks: 32 executed, 8 up-to-date
12:56:13: Task execution finished 'assemble'.
This is a bug with Taplinx version solves in 1.7

Define Checkstyle Task with android gradle plugin 3.4.0

I upgraded my build.gradle file to android gradle plugin 3.4.0 with gradle 5.11.
My build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'checkstyle'
android {
compileSdkVersion 28
buildToolsVersion buildVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "myapp"
minSdkVersion 21
targetSdkVersion 28
versionName "5.20.0"
versionCode 520
}
dataBinding {
enabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation "com.android.support:support-v4:$supportLibVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
task checkstyle(type: Checkstyle) {
source 'src/'
include '**/*.java'
exclude '**/gen/**'
classpath = files()
reports {
xml {
destination "build/outputs/reports/checkstyle-results.xml"
}
}
group = JavaBasePlugin.VERIFICATION_GROUP
description = 'Performs checkstyle verification on the code.'
}
task checkstyleReport(dependsOn: 'checkstyle', group: JavaBasePlugin.VERIFICATION_GROUP) {
if (file("build/outputs/reports/checkstyle-results.xml").exists()) {
ant.xslt(in: "build/outputs/reports/checkstyle-results.xml",
style: "./config/checkstyle/checkstyle.xsl",
out: "build/outputs/reports/checkstyle-results.html"
)
}
}
When syncing I get the following error message:
FAILURE: Build failed with an exception.
Where: Build file '/Users/cs/Development/project/app/build.gradle'
What went wrong: A problem occurred evaluating project ':app'.
Could not find method destination() for arguments [build/outputs/reports/checkstyle-results.xml] on Report xml of type
org.gradle.api.reporting.internal.TaskGeneratedSingleFileReport.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1s ERROR: Gradle DSL method not found: 'destination()'
Possible causes: The project 'project' may be using
a version of the Android Gradle plug-in that does not contain the
method (e.g. 'testCompile' was added in 1.1.0). Upgrade plugin to
version 3.4.0 and sync project
The project 'project' may be using a version of
Gradle that does not contain the method. Open Gradle wrapper file
The build file may be missing a Gradle plugin. Apply Gradle plugin
The error points to this lines:
reports {
xml {
destination "build/outputs/reports/checkstyle-results.xml"
}
}
Has the syntax for destination been changed in gradle?
Solution
reports {
xml {
destination file("build/outputs/reports/checkstyle-results.xml")
}
}
The method used to take an Object, but now requires a File type as a parameter - hence the parameter error.
So passing in a file instead solves the problem.
You can see the expected parameter types here:
https://docs.gradle.org/current/javadoc/org/gradle/api/reporting/ConfigurableReport.html#setDestination-java.io.File-

Android Studio Can not generate signed APK file

Everybody, im trying to generate a signed APK file , with android studio, Firts of all, I changed the "Build variant" from debug to release, then on grade.app minifyEnabled i put true, finally I created my Key and my password, and everything is alright until here, but on my last click, Android studio trys to generate the file but this message comes out
Warning: com.google.android.gms.auth.GoogleAuthUtil: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification
Warning: there were 1 unresolved references to library class members.
You probably need to update the library versions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
:app:proguardRelease FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:proguardRelease'.
java.io.IOException: Please correct the above warnings first.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
im too new with this software , so please be patient with me, i dont know which libraries should i Update.
My compileSdkVersion is 23, and my targed sdk version is 23.
Thanks you all of you.
here is my build.grade file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.manuelrios.aplicacion_inmobiliaria"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:4.2.42'
}
Add the below code in your app gradle
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
.
.
.
lintOptions {
checkReleaseBuilds false
}
}

Cannot resolve the dependencies in gradle build

Recently I have updated the Android Studio and also the SDK.
While rebuilding my app project i m getting following error...
What went wrong:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.android.support:appcompat-v7:23.0.0.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
file:/C:/android new SDK/extras/android/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
file:/C:/android new SDK/extras/android/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
file:/C:/android new SDK/extras/google/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
file:/C:/android new SDK/extras/google/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
Required by:
AppOne:app:unspecified
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.913 secs
...............................................................
My Gradle file config is as follows ..
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
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:23.0.0'
}
Take android sdk manager and update
Android support Library
Android support Repository
It will fix the problem.
You need to install/Update the Android support Library and Android support Repository first and then rebuild the project.

Categories

Resources