In my Android Studio Project I have a pre-built JNI shared library named libNativeExecutor.so compiled with the g++-arm-linux-gnueabi package and I placed a copy of this file in the folder MyProject\app\src\main\jniLibs, a copy in the folder MyProject\app\src\main\jniLibs\arm64-v8a and another copy in the folder MyProject\app\src\main\jniLibs\armeabi-v7a. When I try load this library with this Java code:
...
loadLibrary("NativeExecutor");
...
private void loadLibrary(String name) {
try {
System.loadLibrary(name);
System.out.println(name + " succesfully loaded");
} catch (Throwable exc) {
System.err.println(exc.getMessage());
}
}
... I obtain the following error:
W/System.err: dlopen failed: library "libNativeExecutor.so" not found
I opened with 7-zip the generated apk file located in the folder MyProject\app\build\intermediates\apk\debug but there is no libNativeExecutor.so file within.
I also added this block to the build.gradle file:
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
... This is the structure of my project:
... Anyone know what's wrong? Is it possible that the g++-arm-linux-gnueabi package generates a library that is not compatible and therefore ignored?
Related
Google Drive automatically generates Icon$'\r' in each synced folder in OSX. I'd like to exclude this file Icon$'r' recursively from compilation in Android Studio.
I tried #1 (din't work):
Adding !/**/Icon$'\r' and !/**/Icon' in the following field:
File -> Other Settings -> Default Settings
Build, Execution, Deployment -> Compiler
Resource patterns:
I tried #2 (didn't work):
Adding the following in build.gradle under module:
sourceSets {
main {
java {
srcDir 'src'
exclude '**/Icon$"\r"'
// exclude '**/Icon'
}
}
}
Note:
I already excluded Icon$'\r' in .gitignore
If Icon$'\r' is both excluded at compilation AND hidden, that'd be the best solution.
I've been trying to properly import this library to begin writing an image editing component for my application. I currently have the downloaded 'creativesdk-repo' folder in the root directory, and have followed instructions according to this tutorial:
https://creativesdk.adobe.com/docs/android/#/articles/gettingstarted/index.html.
And this tutorial as well:
https://creativesdk.adobe.com/docs/android/#/articles/imageediting/index.html
There are no problems building when I simply use the basic authorization library, but my application needs photo editing capability. My foremost problem (among many) lies within the build.gradle file of the application (not the encompassing project build.gradle file).
Here is the code in my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "com.example"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.adobe.creativesdk.foundation:auth:0.3.94'
compile 'com.adobe.creativesdk.image:4.0.0'
}
The very last line causes an error message to appear:
Error:Failed to resolve: com.adobe.creativesdk.image:4.0.0:
Open File
I believe these messages mean that the image editing portion of the Adobe Creative SDK libraries are not being recognized. I have even tested this with example projects from Adobe and it runs into the same problem. What can I do to fix this and start writing this portion of my application?
You need download creative-sdk repo from download links into your project folder. In the project gradle define creative-sdk repo url like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
maven{
url "${project.rootDir}/creativesdk-repo" //ADD THE CORRECT LOCATION OF THE CREATIVESDK LIBRARY FILES
}
}
}
In your app build.gradle define this:
compile 'com.adobe.creativesdk.foundation:auth:0.3.94'
compile 'com.adobe.creativesdk:image:4.0.0'
You should extend your Application class and implement this, something like this:
public class ExampleApplication extends MultiDexApplication implements IAdobeAuthClientCredentials , IAviaryClientCredentials {
private static final String CREATIVE_SDK_SAMPLE_CLIENT_ID = "62bbd145c3f54ee39151823358c83e28";
private static final String CREATIVE_SDK_SAMPLE_CLIENT_SECRET = "2522a432-dfc8-40c4-94fe-646e10223562";
#Override
public void onCreate() {
super.onCreate();
AdobeCSDKFoundation.initializeCSDKFoundation(getApplicationContext());
}
#Override
public String getClientID() {
return CREATIVE_SDK_SAMPLE_CLIENT_ID;
}
#Override
public String getClientSecret() {
return CREATIVE_SDK_SAMPLE_CLIENT_SECRET;
}
#Override
public String getBillingKey() {
return "";
}
}
In your AndroidManifest.xml inside Application tag put this:
<provider
android:name="com.aviary.android.feather.sdk.internal.cds.AviaryCdsProvider"
android:authorities="com.package.AviaryCdsProvider"
android:exported="false"
android:process=":aviary_cds" />
With this configuration you can call Aviary Sdk Activity with this:
Intent newIntent = new AviaryIntent.Builder(this);
//config values
startActivity(newIntent);
I configure SDK like this, and its working. Sorry for the delay.
UPDATE 10/10/2016:
Thanks to Ash Ryan:
Trying to make an Android Studio Application with Adobe Creative SDK Image Editing, cannot get libraries compiled in gradle
Use this:
//noinspection SpellCheckingInspection
repositories {
// ...
// For Adobe Creative SDK
maven { url 'https://repo.adobe.com/nexus/content/repositories/releases/' }
}
Source: https://creativesdk.adobe.com/docs/android/#/articles/gettingstarted/index.html
Please make sure under global project repo. If not gradle not able to find the path.
allprojects {
repositories {
compile 'com.adobe.creativesdk.foundation:auth:0.3.94'
compile 'com.adobe.creativesdk:image:4.0.0'
}
I think your error is here. Change:
complie 'com.adobe.creativesdk.image:4.0.0'
for this:
compile 'com.adobe.creativesdk.image:4.0.0'
It`s a simple sintax error.
UPDATE 10/10/2016:
Thanks to Ash Ryan:
Trying to make an Android Studio Application with Adobe Creative SDK Image Editing, cannot get libraries compiled in gradle
just use latest lib dependency in Module:app build.gradle file and update your android sdk and android studio
compile 'com.adobe.creativesdk:image:4.6.3'
I have some code that tries to load a C library as follows :-
public ThreadAffinity() {
ctest = (CTest) Native.loadLibrary("ctest", CTest.class);
}
However I get the following error when trying to build the project; The error I get is as follows :-
UnsatisfiedLinkError: Unable to load library 'libctest': liblibctest.so: cannot open shared object file: No such file or directory
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:166)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:239)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:393)
at com.sun.jna.Native.loadLibrary(Native.java:378)
at com.threads.ThreadAffinity.<init>(ThreadAffinity.java:11)
at com.threads.ThreadAffinity.main(ThreadAffinity.java:45)
The current working directory is the root of the project and thats where the so file is located. I also tried modifying the LD_PRELOAD variable to point to my so file; however the error persists.
It works just fine on my OSX where the dylib is located exactly where the so file is currently(project root).
What am I doing wrong?
From the exception:
UnsatisfiedLinkError: Unable to load library 'libctest': liblibctest.so: cannot open shared object file: No such file or directory
It implies you used something like:
public ThreadAffinity() {
ctest = (CTest) Native.loadLibrary("libctest", CTest.class);
}
and not:
public ThreadAffinity() {
ctest = (CTest) Native.loadLibrary("ctest", CTest.class);
}
hence you see the JNA added prefix of lib and postfix of .so added to libctest (liblibctest.so)
LD_PRELOAD is used when you want to prefer one particular version of the same shared library over another, which doesn't apply here.
Define jna.library.path to point to your project root, and JNA should be able to find it.
Also make sure your library has been built as libctest.so and wasn't inadvertently named libctest.dylib.
In gradle documentation we can read:
For each configuration in your project, Gradle provides the tasks uploadConfigurationName and buildConfigurationName [18].
As I understand I can create build which looks like this (without any plugin because I don't want to use plugins in this project):
configurations {
productSrc
}
// create zip file which will be published
buildProductSrc(type: Copy) << {
// do the job
}
// publish zip which were build by buildProductSrc
uploadProductSrc {
repositories {
ivy {
url "http://ivy.repo/repo"
}
}
}
So if I run gradle buildProductSrc uploadProductSrc it will build zip and piblish it on ivy repository. Do I understand it correctly becouse it doesn't work?
[UPDATE]
According to Peter Niederwieser answer this is a working version of build:
apply plugin: 'base'
configurations {
productSrc
}
// create zip file which will be published
buildProductSrc << { // unable to create specific task, for example 'type: Copy'
// do the job
}
// publish zip which were build by buildProductSrc
uploadProductSrc {
repositories {
ivy {
url "http://ivy.repo/repo"
}
}
}
To get uploadConfigurationName and buildConfigurationName tasks, you'll have to apply the base plugin, or a plugin that in turn applies the base plugin (java, groovy, etc.). Alternatively, you can declare and configure such tasks yourself (but it takes more effort).
I have a gradle build script similar to:
apply plugin: 'war'
task genSources << {
// here I generate some java files
}
// making sure that source files are generated
// before compilation
compileJava.dependsOn(genSources)
How can I make the files generated in genSources compile along with files in src/main/java during compileJava?
You may try adding the path to the generated sources like this:
sourceSets {
main {
java {
srcDir '<path to generatedJava>'
}
}
}