I am trying to build skia for android using the master branch. But I got the following error:
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN11SkJpegCodec6IsJpegEPKvj" referenced by ".../libmyskia.so"...
at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
Some details:
1) The command to build skia:
#!/usr/bin/env bash
echo "generating ninja build files..."
bin/gn gen out/x86 --args='ndk="/Users/rowandjj/Library/Android/sdk/ndk-bundle/" target_cpu="x86" ndk_api=21 target_os="android" is_official_build=false is_component_build=true is_debug=false skia_use_system_expat=false skia_use_system_freetype2=false skia_use_system_libpng=false skia_use_icu=false skia_use_libjpeg_turbo=false skia_use_libwebp=false skia_use_piex=false'
echo "ninja compiling and linking..."
/usr/local/bin/ninja -C out/x86
echo "job done!"
2) The CMakeLists:
cmake_minimum_required(VERSION 3.4.1)
set(distribution_DIR ${CMAKE_SOURCE_DIR}/libs)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/android)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/atlastext)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/c)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/codec)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/config)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/core)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/effects)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/encode)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/gpu)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/pathops)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/ports)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/private)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/svg)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/utils)
add_library( # Sets the name of the library.
myskia
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
IMPORTED )
set_target_properties(
myskia
PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/${ANDROID_ABI}/libmyskia.so
)
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp)
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log)
target_link_libraries( # Specifies the target library.
native-lib
myskia
# Links the target library to the log library
# included in the NDK.
${log-lib})
3) my NDK version: 18.1.5063045
4) gradle version: 4.6 / gradle plugin version: 3.2.1
5) build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.foo.android.helloskia"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
arguments "-DANDROID_PLATFORM=android-26"
cppFlags "-frtti -fexceptions"
}
}
ndk {
abiFilters 'armeabi-v7a',"x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
sourceSets {
main {
jniLibs.srcDir "./libs"
}
}
}
Related
I use lint to check an Android app project:
gradlew lint
It shows the following:
> Task :app:compileOfficialDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
The process generates two files: lint-results.html and lint-results.xml. I checked both files, but could not find any information related to deprecated API. Is it possible to generate more details about deprecated API in these two files?
Here's an example "build.gradle" I marked up:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
multiDexEnabled true
applicationId "com.boxpik.android"
minSdkVersion 17
targetSdkVersion 19
...
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
...
In this example, I added options.compilerArgs << "-Xlint:all" to build.gradle.
This gave me a bunch of Lint warning in my Android Studio "Build" window:
^
C:\xyz\PoolToScoreDetailFragment.java:55: warning: [deprecation] ProgressDialog in android.app has been deprecated
private ProgressDialog pDialog;
^
C:\xyz\PoolToScoreDetailFragment.java:346: warning: [deprecation] ProgressDialog in android.app has been deprecated
pDialog = new ProgressDialog(application);
I am getting a DuplicateFileException while building Apk. I used the Applogic source code from GitHub to develop a chat app and while building the gradle I got this exception not able to build the apk. I am using Android Studio 3.0 Gradle version 3.3 and Android Plugin version 2.3.3 Build tool version 26.0.2 sdk version API26
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.mobicomkit.sample"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ECLIPSE_.SF'
exclude 'META-INF/ECLIPSE_.RSA'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':mobicomkitui') //Note: use this for customization
compile 'com.applozic.communication.uiwidget:mobicomkitui:5.2'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:cardview-v7:26.0'
compile 'com.android.support:recyclerview-v7:26.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.7#aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'enter image description here
You cant use the both at a time gradle dependency and imported applozic source code and any one you need to use
Use this in your case you imported source code
compile project(':mobicomkitui') //Note: use this for customization
Remove this code from your app build.gradle file
compile 'com.applozic.communication.uiwidget:mobicomkitui:5.2'
I migrated source code from Eclipse to Android studio, when I build the project in android studio, I got the following failure.
FAILURE: Build failed with an exception.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelper$1.class
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile (project(':facebook')){
exclude group: 'com.android.support', module: 'multidex'
}
compile project(':libraryBasePera')
compile project(':google-play-services_lib')
compile 'com.android.support:multidex:1.0.1'
}
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
I tried many ways (exclude module support-v4, deleted support-v4 jar, clean, rebuild project...) but I am still stuck here. Can any one help me to figure out the problem?
Thank you very much.
Try to check lib folder. I had same error because I have added support-v4 jar in my lib folder by mistake.
So I finally managed to get my android studio to run JUnit test that's integrated with robolectric so I can do http calls and other things without running it on device or emulator. Followed the structure from here which worked wonders: https://github.com/robolectric/deckard-gradle
Now, I managed to run it fine on AndroidStudio, however I want to setup a cron so it can be run automatically, and when executing the test by command line via gradle I am getting "java.lang.UnsatisfiedLinkError: no pjsua in java.library.path". Note that our code uses a pjsip lib code that we compile separately, and we put the .so file in the jniLibs folder. I have another jUnit test that's really simple, and that one works fine whether through gradle command line or AndroidStudio.
The gradle command I followed from http://tools.android.com/tech-docs/unit-testing-support which are either:
1) ./gradlew test --continue
or
2) ./gradlew test -Dtest.single=Test.java
This is what our gradle file looks like for the app layer:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.foo.test"
minSdkVersion 14
targetSdkVersion 21
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
moduleName "libpjsua"
}
}
sourceSets {
main {
jni.srcDirs = []
}
}
signingConfigs {
// hidden
}
buildTypes {
release {
signingConfig signingConfigs.release
}
debug {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/android-logging-log4j-1.0.3.jar')
compile files('libs/libphonenumber-6.2.jar')
compile files('libs/log4j-1.2.17.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/ostermillerutils_1_07_00.jar')
// dependencies to do automation testing
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-core:1.1'
testCompile 'org.hamcrest:hamcrest-library:1.1'
testCompile 'org.hamcrest:hamcrest-integration:1.1'
testCompile('org.robolectric:robolectric:2.4') {
exclude module: 'classworlds'
exclude module: 'commons-logging'
exclude module: 'httpclient'
exclude module: 'maven-artifact'
exclude module: 'maven-artifact-manager'
exclude module: 'maven-error-diagnostics'
exclude module: 'maven-model'
exclude module: 'maven-project'
exclude module: 'maven-settings'
exclude module: 'plexus-container-default'
exclude module: 'plexus-interpolation'
exclude module: 'plexus-utils'
exclude module: 'wagon-file'
exclude module: 'wagon-http-lightweight'
exclude module: 'wagon-provider-api'
}
}
Does anyone have any idea? Many thanks in advance, been at this for a couple of days now.
This must be straight forward but I fail to see where group: name: and version: come from for a particular jar file. For example from Gradle's documentation.
dependencies {
compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
testCompile group: 'junit', name: 'junit', version: '4.+'
testRuntime "org.hamcrest:SelfDescribing:1.+"
}
I'm trying to make use of a hamcrest jar for my junit testing. I need hamcrest for runtime testing but I don't know how to correctly specify this. Below is my build.gradle file. This test project will build successfully but will not run the unit tests due to unresolved dependencies.
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
version = '1.0'
compileJava.destinationDir = file("$buildDir/classes/test")
sourceSets {
main {
java {
srcDir 'src'
}
}
}
repositories {
flatDir dirs: "C:/eclipse/plugins/org.junit_4.11.0.v201303080030"
flatDir dirs: "C:/eclipse/plugins"
}
dependencies {
compile "junit:junit:4"
testCompile "junit:junit:4"
testRuntime "org.hamcrest:SelfDescribing:1.+"
}
test {
testLogging.showStandardStreams = true
testLogging {
events 'started', 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
exceptionFormat 'short'
}
}
jar {
manifest.attributes provider: 'gradle'
}
To add a dependency on a jar file, add a statement like this to your dependencies block:
compile files('path/to/archive.jar')
A popular approach is this, which will automatically pick up all jar files in a libs directory:
compile fileTree(dir: 'path/to/libs', include: '*.jar')
When using a flatDir repository, you'll have to make sure that:
Artifact files are contained directly in the specified directory (not in a subdirectory).
Artifact filenames match the pattern module-version.extension (e.g. junit-4.jar) or module.extension (e.g. junit.jar).
Alternatively, you could use file dependencies as described in Scott's answer.
PS: I'm not sure if version ranges work with flatDir repositories.