I have this code and I do not understand why my IDNarray image is returning me null when I try convert Mat in INDArray.
I using the android sutdio 3.0.1.
//************************* Digit classification *******************************************************************
for (int i = 0; i < rects.size() ; i++) {
Rect rect = rects.get(i);
digit = inverted.submat(rect.y, rect.y + rect.height, rect.x, rect.x + rect.width);
Imgproc.resize(digit, digit, new Size(28, 28));
NativeImageLoader nativeImageLoader = new NativeImageLoader(digit.height(), digit.width(), digit.channels());//Use the nativeImageLoader to convert to numerical matrix
INDArray image = nativeImageLoader.asMatrix(digit);//put image into INDArray
System.out.println("carregar modelo matrixes " + image);
}
output: carregar modelo matrixes NULL
Again, please make sure to upload the image. If we can't reproduce it, I am closing this.
@agibsonccc
short code..
public void openGallery( View view){
Intent myIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI );
startActivityForResult(myIntent, 100);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 100 && resultCode == RESULT_OK && data !=null){
imageUri = data.getData();
try{
imageBitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),imageUri);
}catch ( IOException e)
{
e.printStackTrace();
}
imView.setImageBitmap(imageBitmap);
}
}
public void convertGray(View view) throws IOException {
Mat Rgba = new Mat();
BitmapFactory.Options o = new BitmapFactory.Options();
o.inDither = false;
o.inSampleSize = 4;
// convert bitmap to Mat
Utils.bitmapToMat(imageBitmap, Rgba);
NativeImageLoader nativeImageLoader = new NativeImageLoader(28, 28,1);
INDArray image = nativeImageLoader.asMatrix(Rgba);//put image into INDArray
System.out.println("carregar modelo matrixes " + image);
}
You'll need to convert the Mat to a JavaCPP Mat like this: https://github.com/bytedeco/javacpp/issues/38#issuecomment-140728812
I should probably put that somewhere in the code...
Call new Mat((Pointer)null) { { address = digit.getNativeObjAddr(); } }; and use that.
Mat mat2 = new Mat((Pointer)null) { { address = digit.getNativeObjAddr(); } };
Mat mat = new Mat(mat2.address());
when I use both codes gives me the message: cannot resolve symbol 'address'
To refer to both Mat types in the same file, you'll need to use their fully qualified names: org.bytedeco.javacpp.opencv_core.Mat and org.opencv.core.Mat.
final Mat finalDigit = digit;
org.bytedeco.javacpp.opencv_core.Mat img = new rg.bytedeco.javacpp.opencv_core.Mat((Pointer)null) {{ address = finalDigit.getNativeObjAddr();}};
NativeImageLoader nativeImageLoader = new NativeImageLoader(digit.height(), digit.width(), digit.channels());//Use the nativeImageLoader to convert to numerical matrix
INDArray image = nativeImageLoader.asMatrix(img);//put image into INDArray
System.out.println("carregar modelo matrixes " + image);
This worked for me, but the output of the matrix are with values giving zero, this is how it should be?
[[[[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
I/System.out: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]]]
Probably not, make sure you're not trying to use multiple versions of OpenCV together: Use JavaCV only.
Would this be, instead of using opencv to use javaCv throughout my code?
JavaCV supports the official Java API of OpenCV, no need to change anything but in your build files.
hum .. and any tips on how to proceed?
Use the dependencies that I've updated in commit https://github.com/deeplearning4j/deeplearning4j/commit/ac91961036f83a1ca5055db93223e81bcf443ed9 or available in the examples at https://github.com/deeplearning4j/dl4j-examples/tree/master/android and it will work fine.
when I upgrade to beta2, NativeImageLoader is not in the package and displays the message can not resolve symbol.
so I added
compile 'org.datavec: datavec-data-image: 1.0.0-beta2' and solved this, but when compiling gave another error
Error: Execution failed for task ': app: transformResourcesWithMergeJavaResForDebug'.
More than one file was found with OS independent path 'org / bytedeco / javacpp / windows-x86_64 / api-ms-win-crt-locale-l1-1-0.dll'
How do I solve it?
Use the same exclude as deeplearning4j-nn, which BTW depends on
datavec-data-image so no need to list it explicitly.
So I have to include?
sorry for such questions is that I am still learning about this and some things are still new to me.
Hum, looks like that was changed back recently. Replace deeplearning4j-nn with deeplearning4j-core as with commits https://github.com/deeplearning4j/deeplearning4j/commit/feb96d06b0585926039593d9e798c9fe7fcce510 and https://github.com/deeplearning4j/dl4j-examples/commit/5381c5f86170dc544522eb7926d8fbf8119bec67, that works with 1.0.0-beta2.
replace e deeplearning4j-nn with deeplearning4j-core work, but when compiling, this error appears below in the line: MultiLayerNetwork model = ModelSerializer.restoreMultiLayerNetwork (inputStream);
here is the code:
try {
// Load the pretrained network.
InputStream inputStream = getResources().openRawResource(R.raw.classecharacter);
MultiLayerNetwork model = ModelSerializer.restoreMultiLayerNetwork(inputStream);
NativeImageLoader nativeImageLoader = new NativeImageLoader(28, 28, 1);//Use the nativeImageLoader to convert to numerical matrix
INDArray imageArray = nativeImageLoader.asMatrix(digito);//put image into INDArray
here is the error
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ailton.converttogray, PID: 26958
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java:5242)
at android.widget.TextView.performClick(TextView.java:10571)
at android.view.View$PerformClick.run(View.java:21196)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:5242)聽
at android.widget.TextView.performClick(TextView.java:10571)聽
at android.view.View$PerformClick.run(View.java:21196)聽
at android.os.Handler.handleCallback(Handler.java:739)聽
at android.os.Handler.dispatchMessage(Handler.java:95)聽
at android.os.Looper.loop(Looper.java:145)聽
at android.app.ActivityThread.main(ActivityThread.java:6938)聽
at java.lang.reflect.Method.invoke(Native Method)聽
at java.lang.reflect.Method.invoke(Method.java:372)聽
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)聽
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)聽
Caused by: java.lang.ClassCastException: org.bytedeco.javacpp.indexer.LongBufferIndexer cannot be cast to org.bytedeco.javacpp.indexer.LongRawIndexer
at org.nd4j.linalg.api.buffer.BaseDataBuffer.put(BaseDataBuffer.java:1219)
at org.nd4j.linalg.api.ndarray.BaseShapeInfoProvider.createShapeInformation(BaseShapeInfoProvider.java:87)
at org.nd4j.linalg.cpu.nativecpu.DirectShapeInfoProvider.createShapeInformation(DirectShapeInfoProvider.java:59)
at org.nd4j.linalg.cpu.nativecpu.DirectShapeInfoProvider.createShapeInformation(DirectShapeInfoProvider.java:44)
at org.nd4j.linalg.api.ndarray.BaseNDArray.<init>(BaseNDArray.java:172)
at org.nd4j.linalg.cpu.nativecpu.NDArray.<init>(NDArray.java:77)
at org.nd4j.linalg.cpu.nativecpu.CpuNDArrayFactory.create(CpuNDArrayFactory.java:205)
at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:3928)
at org.nd4j.linalg.factory.Nd4j.createArrayFromShapeBuffer(Nd4j.java:2397)
at org.nd4j.linalg.factory.Nd4j.read(Nd4j.java:2436)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:254)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:342)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:361)
at com.example.ailton.converttogray.MainActivity.convertGray(MainActivity.java:314)
at java.lang.reflect.Method.invoke(Native Method)聽
at java.lang.reflect.Method.invoke(Method.java:372)聽
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)聽
at android.view.View.performClick(View.java:5242)聽
at android.widget.TextView.performClick(TextView.java:10571)聽
at android.view.View$PerformClick.run(View.java:21196)聽
at android.os.Handler.handleCallback(Handler.java:739)聽
at android.os.Handler.dispatchMessage(Handler.java:95)聽
at android.os.Looper.loop(Looper.java:145)聽
at android.app.ActivityThread.main(ActivityThread.java:6938)聽
at java.lang.reflect.Method.invoke(Native Method)聽
at java.lang.reflect.Method.invoke(Method.java:372)聽
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)聽
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)聽
@raver119 this doesn't tlook right, do you know where this might be coming from? When we use indexer, we should try to stick to the interface, not the implementation.
It looks like we had a typo here? https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-buffer/src/main/java/org/nd4j/linalg/api/buffer/BaseDataBuffer.java#L1219
What's digito?
Does it do the same with a File? If you could post a model file to reproduce this, please do. Thanks!
package com.example.ailton.converttogray;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.opencv_core;
import org.datavec.image.loader.AndroidNativeImageLoader;
import org.datavec.image.loader.NativeImageLoader;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
import org.deeplearning4j.util.ModelSerializer;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.opencv.android.OpenCVLoader;
import org.opencv.android.Utils;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.MatOfPoint2f;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.RotatedRect;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.CoderResult;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
ImageView imView;
Uri imageUri;
Bitmap grayBitmap, imageBitmap;
MultiLayerNetwork model;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
OpenCVLoader.initDebug();
imView = (ImageView) findViewById(R.id.imView);
}
public void openGallery( View view){
Intent myIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI );
startActivityForResult(myIntent, 100);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 100 && resultCode == RESULT_OK && data !=null){
imageUri = data.getData();
try{
imageBitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),imageUri);
}catch ( IOException e)
{
e.printStackTrace();
}
imView.setImageBitmap(imageBitmap);
}
}
public void convertGray(View view) throws IOException {
Mat Rgba = new Mat();
Mat grayMat = new Mat();
BitmapFactory.Options o = new BitmapFactory.Options();
o.inDither = false;
o.inSampleSize = 4;
int width = imageBitmap.getWidth();
int height = imageBitmap.getHeight();
grayBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
// convert bitmap to Mat
Utils.bitmapToMat(imageBitmap, Rgba);
// cinza
Imgproc.cvtColor(Rgba, grayMat, Imgproc.COLOR_RGB2GRAY);
final Mat finalDigit = grayMat;
//convert opencv Mat to javaCpp
org.bytedeco.javacpp.opencv_core.Mat digito = new org.bytedeco.javacpp.opencv_core.Mat((Pointer)null) {{ address = finalDigit.getNativeObjAddr();}};
try {
// Load the pretrained network.
InputStream inputStream = getResources().openRawResource(R.raw.classecharacter);
model = ModelSerializer.restoreMultiLayerNetwork(inputStream);
NativeImageLoader nativeImageLoader = new NativeImageLoader(28, 28, 1);//Use the nativeImageLoader to convert to numerical matrix
INDArray imageArray = nativeImageLoader.asMatrix(digito);//put image into INDArray
System.out.println("Indarray 茅 " + imageArray);
// INDArray flaten;
//flaten = image != null ? image.reshape(new int[]{1, 784}) : null; // ordena os vetores em 28*28 = 784
//pass through neural net and store it in output array
INDArray output = model.output(imageArray);
System.out.println("A saida 茅 " + output);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Ok, thanks, that looks alright. It looks like something is strange with the model file that you have. Could you try to load on the desktop? I think it will succeed because we can use LongRawIndexer, but not on Android...
load on the desktop, how?
I just mean running your code on Linux, Mac, or Windows, it probably works there. This is probably an issue with Android only.
but it is that I am developing an app for android, so it is necessary to do the compilation on android using android studio.
How do I make the changes that were made e90d68e?
Where do I make the updates?
@AILTON091 you will have to use snapshots.
There are instructions for that here:
https://deeplearning4j.org/docs/latest/deeplearning4j-android
Sorry for the delay in answering.
these are my files build.glade and pom.xml ..
I added the pom.xml file and I ran mvn compile and it is still giving the same error ..
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ snapshots ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
build.glade
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.ailton.converttogray"
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
//some exclusions are needed
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
externalNativeBuild {
ndkBuild {
path '../../DetetordePlacas/app/build/intermediates/ndk/debug/Android.mk'
}
}
allprojects {
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation project(':openCVLibrary340')
compile "org.slf4j:slf4j-api:1.7.25"
compile "org.slf4j:slf4j-simple:1.7.25"
compile (group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '1.0.0-beta') {
exclude group: 'org.bytedeco.javacpp-presets', module: 'opencv-platform'
exclude group: 'org.bytedeco.javacpp-presets', module: 'leptonica-platform'
exclude group: 'org.bytedeco.javacpp-presets', module: 'hdf5-platform'
}
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2'
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-arm"
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-arm64"
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-x86"
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-x86_64"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86_64"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86_64"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86_64"
implementation 'com.google.code.gson:gson:2.8.2'
annotationProcessor 'org.projectlombok:lombok:1.16.16'
//This corrects for a junit version conflict.
configurations.all {
resolutionStrategy.force 'junit:junit:4.12'
}
compile 'com.google.code.findbugs:annotations:3.0.1', {
exclude module: 'jsr305'
exclude module: 'jcip-annotations'
}
}
}
apply plugin: 'com.google.gms.google-services'
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.deeplearning4j</groupId>
<artifactId>snapshots</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
You need to use 1.0.0-SNAPSHOT, not 1.0.0-beta or 1.0.0-beta2. Change those
to 1.0.0-SNAPSHOT.
I made this snapshot change but it's still giving even that up, I do not know if I'm doing anything wrong with installing the pom.xml file
Could you show what your updated build.gradle looks like?
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.ailton.converttogray"
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
//some exclusions are needed
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
externalNativeBuild {
ndkBuild {
path '../../DetetordePlacas/app/build/intermediates/ndk/debug/Android.mk'
}
}
allprojects {
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation project(':openCVLibrary340')
compile "org.slf4j:slf4j-api:1.7.25"
compile "org.slf4j:slf4j-simple:1.7.25"
compile (group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '1.0.0-SNAPSHOT') {
exclude group: 'org.bytedeco.javacpp-presets', module: 'opencv-platform'
exclude group: 'org.bytedeco.javacpp-presets', module: 'leptonica-platform'
exclude group: 'org.bytedeco.javacpp-presets', module: 'hdf5-platform'
}
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86_64"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86_64"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86_64"
implementation 'com.google.code.gson:gson:2.8.2'
annotationProcessor 'org.projectlombok:lombok:1.16.16'
//This corrects for a junit version conflict.
configurations.all {
resolutionStrategy.force 'junit:junit:4.12'
}
compile 'com.google.code.findbugs:annotations:3.0.1', {
exclude module: 'jsr305'
exclude module: 'jcip-annotations'
}
}
}
apply plugin: 'com.google.gms.google-services'
the files in pom.xml are right?
Yes, that looks alright... Here's the issue, snapshots haven't been updated lately:
https://oss.sonatype.org/content/repositories/snapshots/org/nd4j/nd4j-native/1.0.0-SNAPSHOT/
We'll need to wait until @sshepel gets around to fixing this...
could you let me know that the update is available? thanks
Hello @saudet , some news about the snapshot update.
thank you.
@AILTON091 They've been back for a couple of weeks now. They are still not working for you?
yes. It still does not work for me. :/
What issue are you having these days? Please provide more details.
I'm using android studio 3.0.1, with 'deeplearning4j-core', version: '1.0.0-SNAPSHOT'
the error appears when loading the model in ModelSerializer.restoreMultiLayerNetwork (inputStream); I do not know what happens.
as I said in the comments but above, when I use the deeplearning4j-nn-
1.0.0-beta works fine, but the output matrix in the asMatrix function returns me all values as zero.
error
Caused by: java.lang.ClassCastException: org.bytedeco.javacpp.indexer.LongBufferIndexer cannot be cast to org.bytedeco.javacpp.indexer.LongRawIndexer
at org.nd4j.linalg.api.buffer.BaseDataBuffer.put(BaseDataBuffer.java:1219)
at org.nd4j.linalg.api.ndarray.BaseShapeInfoProvider.createShapeInformation(BaseShapeInfoProvider.java:87)
at org.nd4j.linalg.cpu.nativecpu.DirectShapeInfoProvider.createShapeInformation(DirectShapeInfoProvider.java:59)
at org.nd4j.linalg.cpu.nativecpu.DirectShapeInfoProvider.createShapeInformation(DirectShapeInfoProvider.java:44)
at org.nd4j.linalg.api.ndarray.BaseNDArray.<init>(BaseNDArray.java:172)
at org.nd4j.linalg.cpu.nativecpu.NDArray.<init>(NDArray.java:77)
at org.nd4j.linalg.cpu.nativecpu.CpuNDArrayFactory.create(CpuNDArrayFactory.java:205)
at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:3928)
at org.nd4j.linalg.factory.Nd4j.createArrayFromShapeBuffer(Nd4j.java:2397)
at org.nd4j.linalg.factory.Nd4j.read(Nd4j.java:2436)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:254)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:342)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:361)
at org.deeplearning4j.examples.image_recognition_demo.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:73)
at org.deeplearning4j.examples.image_recognition_demo.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:54)
pom.xml
<project >
<modelVersion>4.0.0</modelVersion>
<groupId>org.deeplearning4j</groupId>
<artifactId>snapshots</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
Did you also run mvn -U compile?
yes, i done it.
Ok, well anyway the code in the snapshots do not reference LongRawIndexer anywhere anymore:
https://github.com/deeplearning4j/deeplearning4j/search?q=LongRawIndexer
So you have old classes somewhere on your system. Please find them and remove them.
I searched the LongRawIndexer and found the LongRawIndexer.java is the one I have to remove?
/*
* Copyright (C) 2016 Samuel Audet
*
* Licensed either under the Apache License, Version 2.0, or (at your option)
* under the terms of the GNU General Public License as published by
* the Free Software Foundation (subject to the "Classpath" exception),
* either version 2, or any later version (collectively, the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.gnu.org/licenses/
* http://www.gnu.org/software/classpath/license.html
*
* or as provided in the LICENSE.txt file that accompanied this code.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bytedeco.javacpp.indexer;
import org.bytedeco.javacpp.LongPointer;
import org.bytedeco.javacpp.Pointer;
/**
* An indexer for a {@link LongPointer} using the {@link Raw} instance.
*
* @author Samuel Audet
*/
public class LongRawIndexer extends LongIndexer {
/** The instance for the raw memory interface. */
protected static final Raw RAW = Raw.getInstance();
/** The backing pointer. */
protected LongPointer pointer;
/** Base address and number of elements accessible. */
final long base, size;
/** Calls {@code LongRawIndexer(pointer, { pointer.limit() - pointer.position() }, { 1 })}. */
public LongRawIndexer(LongPointer pointer) {
this(pointer, new long[] { pointer.limit() - pointer.position() }, ONE_STRIDE);
}
/** Constructor to set the {@link #pointer}, {@link #sizes} and {@link #strides}. */
public LongRawIndexer(LongPointer pointer, long[] sizes, long[] strides) {
super(sizes, strides);
this.pointer = pointer;
base = pointer.address() + pointer.position() * VALUE_BYTES;
size = pointer.limit() - pointer.position();
}
@Override public Pointer pointer() {
return pointer;
}
@Override public long get(long i) {
return RAW.getLong(base + checkIndex(i, size) * VALUE_BYTES);
}
@Override public LongIndexer get(long i, long[] l, int offset, int length) {
for (int n = 0; n < length; n++) {
l[offset + n] = get(i * strides[0] + n);
}
return this;
}
@Override public long get(long i, long j) {
return get(i * strides[0] + j);
}
@Override public LongIndexer get(long i, long j, long[] l, int offset, int length) {
for (int n = 0; n < length; n++) {
l[offset + n] = get(i * strides[0] + j * strides[1] + n);
}
return this;
}
@Override public long get(long i, long j, long k) {
return get(i * strides[0] + j * strides[1] + k);
}
@Override public long get(long... indices) {
return get(index(indices));
}
@Override public LongIndexer get(long[] indices, long[] l, int offset, int length) {
for (int n = 0; n < length; n++) {
l[offset + n] = get(index(indices) + n);
}
return this;
}
@Override public LongIndexer put(long i, long l) {
RAW.putLong(base + checkIndex(i, size) * VALUE_BYTES, l);
return this;
}
@Override public LongIndexer put(long i, long[] l, int offset, int length) {
for (int n = 0; n < length; n++) {
put(i * strides[0] + n, l[offset + n]);
}
return this;
}
@Override public LongIndexer put(long i, long j, long l) {
put(i * strides[0] + j, l);
return this;
}
@Override public LongIndexer put(long i, long j, long[] l, int offset, int length) {
for (int n = 0; n < length; n++) {
put(i * strides[0] + j * strides[1] + n, l[offset + n]);
}
return this;
}
@Override public LongIndexer put(long i, long j, long k, long l) {
put(i * strides[0] + j * strides[1] + k, l);
return this;
}
@Override public LongIndexer put(long[] indices, long l) {
put(index(indices), l);
return this;
}
@Override public LongIndexer put(long[] indices, long[] l, int offset, int length) {
for (int n = 0; n < length; n++) {
put(index(indices) + n, l[offset + n]);
}
return this;
}
@Override public void release() { pointer = null; }
}
No, not that. Anyway, delete ~/.m2/repository/ and ~/.gradle/caches/ for starters and if that doesn't work, recreate your Android project from scratch according to these instructions: http://deeplearning4j.org/android
the same error that has occurred with the application that I am developing is the same as when I use the example of Digit recognition, error in LongRawIndexer in version SNAPSHOT.
I find that very strange.
The code you're referring to doesn't exist in the repository anymore!
I'm talking about that code https://github.com/deeplearning4j/dl4j-examples/commit/5381c5f86170dc544522eb7926d8fbf8119bec67
never worked in any version of deeplearning I do not know if it is something with the version of the cell where emulando empu is a samsung galaxy s5 where the minimum API is 22 or some andriod configuration.
Ok, so what error are you getting? I've tested that example and it works fine in the emulator, at least.
still the same error.
I/art: Explicit concurrent mark sweep GC freed 370(32KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 13MB/23MB, paused 707us total 56.590ms
W/System.err: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
W/System.err: SLF4J: Defaulting to no-operation (NOP) logger implementation
W/System.err: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.nd4j.versioncheck.VersionCheck$1>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.nd4j.versioncheck.VersionCheck$1>
W/linker: libnd4jcpu.so: unused DT entry: type 0x6ffffffe arg 0x1ee6b0
W/linker: libnd4jcpu.so: unused DT entry: type 0x6fffffff arg 0x2
W/linker: libjnind4jcpu.so: unused DT entry: type 0x1d arg 0x9e3db
W/linker: libjnind4jcpu.so: unused DT entry: type 0x6ffffffe arg 0xd54c0
W/linker: libjnind4jcpu.so: unused DT entry: type 0x6fffffff arg 0x3
W/linker: libopenblas.so: unused DT entry: type 0x6ffffffe arg 0x121bc
W/linker: libopenblas.so: unused DT entry: type 0x6fffffff arg 0x2
W/linker: libjniopenblas_nolapack.so: unused DT entry: type 0xf arg 0x9f29
W/linker: libjniopenblas_nolapack.so: unused DT entry: type 0x6ffffffe arg 0xe77c
W/linker: libjniopenblas_nolapack.so: unused DT entry: type 0x6fffffff arg 0x2
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: org.deeplearning4j.examples.image_recognition_demo, PID: 2271
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassCastException: org.bytedeco.javacpp.indexer.LongBufferIndexer cannot be cast to org.bytedeco.javacpp.indexer.LongRawIndexer
at org.nd4j.linalg.api.buffer.BaseDataBuffer.put(BaseDataBuffer.java:1219)
at org.nd4j.linalg.api.ndarray.BaseShapeInfoProvider.createShapeInformation(BaseShapeInfoProvider.java:87)
at org.nd4j.linalg.cpu.nativecpu.DirectShapeInfoProvider.createShapeInformation(DirectShapeInfoProvider.java:59)
at org.nd4j.linalg.cpu.nativecpu.DirectShapeInfoProvider.createShapeInformation(DirectShapeInfoProvider.java:44)
at org.nd4j.linalg.api.ndarray.BaseNDArray.<init>(BaseNDArray.java:172)
at org.nd4j.linalg.cpu.nativecpu.NDArray.<init>(NDArray.java:77)
at org.nd4j.linalg.cpu.nativecpu.CpuNDArrayFactory.create(CpuNDArrayFactory.java:205)
at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:3928)
at org.nd4j.linalg.factory.Nd4j.createArrayFromShapeBuffer(Nd4j.java:2397)
at org.nd4j.linalg.factory.Nd4j.read(Nd4j.java:2436)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:254)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:342)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:361)
at org.deeplearning4j.examples.image_recognition_demo.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:73)
at org.deeplearning4j.examples.image_recognition_demo.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:54)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
So, I'll say it again, you're not using the latest version of the code. See line 1219 of BaseDataBuffer.java here:
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-buffer/src/main/java/org/nd4j/linalg/api/buffer/BaseDataBuffer.java#L1219
There are no references to LongRawIndexer anymore. You'll need to use that version if you expect to get this running, it's that simple!
send me the latest version so I can do the test please, if it is SNAPSHOT could you give me a version of what comes within the pom.xml file? in the code above I was using beta2
You'll need to use that version if you expect to get this running, it's that simple!
what is the version that does not have LongRawIndexer I can not find.
I told you, you'll need to use 1.0.0-SNAPSHOT. If you're not able to get that working with the instructions I gave you, please wait for the next release.
So i changed the version to 1.0.0-SNAPSHOT then i get dependency error
09-30 13:23:18.291 28422-28800/com.example.titamrtn.formedetection E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.example.titamrtn.formedetection, PID: 28422
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ExceptionInInitializerError
at org.nd4j.nativeblas.NativeOpsHolder.getInstance(NativeOpsHolder.java:75)
at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.<init>(NativeOpExecutioner.java:69)
at java.lang.Class.newInstance(Native Method)
at org.nd4j.linalg.factory.Nd4j.initWithBackend(Nd4j.java:5578)
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5473)
at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:214)
at org.nd4j.linalg.factory.Nd4j.read(Nd4j.java:2432)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:254)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:342)
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:361)
at com.example.titamrtn.formedetection.CameraActivity$PredictTask.doInBackground(CameraActivity.java:263)
at com.example.titamrtn.formedetection.CameraActivity$PredictTask.doInBackground(CameraActivity.java:239)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)聽
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)聽
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)聽
at java.lang.Thread.run(Thread.java:818)聽
Caused by: java.lang.RuntimeException: ND4J is probably missing dependencies. For more information, please refer to: http://nd4j.org/getstarted.html
at org.nd4j.nativeblas.NativeOpsHolder.<init>(NativeOpsHolder.java:68)
at org.nd4j.nativeblas.NativeOpsHolder.<clinit>(NativeOpsHolder.java:36)
at org.nd4j.nativeblas.NativeOpsHolder.getInstance(NativeOpsHolder.java:75)聽
at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.<init>(NativeOpExecutioner.java:69)聽
at java.lang.Class.newInstance(Native Method)聽
at org.nd4j.linalg.factory.Nd4j.initWithBackend(Nd4j.java:5578)聽
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5473)聽
at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:214)聽
at org.nd4j.linalg.factory.Nd4j.read(Nd4j.java:2432)聽
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:254)聽
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:342)聽
at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:361)聽
at com.example.titamrtn.formedetection.CameraActivity$PredictTask.doInBackground(CameraActivity.java:263)聽
at com.example.titamrtn.formedetection.CameraActivity$PredictTask.doInBackground(CameraActivity.java:239)聽
at android.os.AsyncTask$2.call(AsyncTask.java:295)聽
at java.util.concurrent.FutureTask.run(FutureTask.java:237)聽
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)聽
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)聽
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)聽
at java.lang.Thread.run(Thread.java:818)聽
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.titamrtn.formedetection-2/base.apk", zip file "/data/app/com.example.titamrtn.formedetection-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.titamrtn.formedetection-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.titamrtn.formedetection-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.titamrtn.formedetection-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.titamrtn.formedetection-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.titamrtn.formedetection-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.titamrtn.formedetection-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.titamrtn.formedetection-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.titamrtn.formedetection-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.titamrtn.formedetection-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.titamrtn.formedetection-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.titamrtn.formedetection-2/lib/arm64, /data/app/com.example.titamrtn.formedetection-2/base.apk!/lib/arm64-v8a, /data/app/com.example.titamrtn.formedetection-2/split_lib_dependencies_apk.apk!/lib/arm64-v8a, /data/app/com.example.titamrtn.formedetection-2/split_lib_slice_0_apk.apk!/lib/arm64-v8a, /data/app/com.example.titamrtn.formedetection-2/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /data/app/com.example.titamrtn.formedetection-2/split_lib_slice_2_apk.apk!/lib/arm64-v8a, /data/app/com.example.titamrtn.formedetection-2/split_lib_slice_3_apk.apk!/lib/arm64-v8a, /data/app/com.example.titamrtn.formedetection-2/split_lib_slice_4_apk.apk!/lib/arm64-v8a, /data/app/com.example.titamrtn.formedetection-2/split_lib_slice_5_apk.apk!/lib/arm64-v8a, /data/app/com.example.tit
09-30 13:23:18.435 28422-28800/com.example.titamrtn.formedetection I/Process: Sending signal. PID: 28422 SIG: 9
This is my gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.titamrtn.formedetection"
minSdkVersion 23
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'
}
}
}
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
compile "org.slf4j:slf4j-api:1.7.25"
compile "org.slf4j:slf4j-simple:1.7.25"
compile (group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '1.0.0-SNAPSHOT') {
exclude group: 'org.bytedeco.javacpp-presets', module: 'opencv-platform'
exclude group: 'org.bytedeco.javacpp-presets', module: 'leptonica-platform'
exclude group: 'org.bytedeco.javacpp-presets', module: 'hdf5-platform'
}
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86_64"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86_64"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86_64"
annotationProcessor 'org.projectlombok:lombok:1.16.16'
compile 'com.google.code.findbugs:annotations:3.0.1', {
exclude module: 'jsr305'
exclude module: 'jcip-annotations'
}
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
And my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.deeplearning4j</groupId>
<artifactId>snapshots</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
You didn't include the native binaries for nd4j, that's not going to work: http://deeplearning4j.org/android
So i change pom to add this
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-arm"
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-arm64"
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-x86"
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-x86_64"
And i got this error when building gradle
Failed to resolve: nd4j-native-android-arm
Failed to resolve: nd4j-native-android-arm64
Failed to resolve: nd4j-native-android-x86
Unable to resolve dependency for ':app@debug/compileClasspath': Could not find nd4j-native-android-x86_64.jar (org.nd4j:nd4j-native:1.0.0-SNAPSHOT).
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not find nd4j-native-android-x86_64.jar (org.nd4j:nd4j-native:1.0.0-SNAPSHOT).
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not find nd4j-native-android-x86_64.jar (org.nd4j:nd4j-native:1.0.0-SNAPSHOT).
Unable to resolve dependency for ':app@release/compileClasspath': Could not find nd4j-native-android-x86_64.jar (org.nd4j:nd4j-native:1.0.0-SNAPSHOT).
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not find nd4j-native-android-x86_64.jar (org.nd4j:nd4j-native:1.0.0-SNAPSHOT).
And if i use 1.0.0-beta2 version of nd4j i got the previous error
Caused by: java.lang.ClassCastException: org.bytedeco.javacpp.indexer.LongBufferIndexer cannot be cast to org.bytedeco.javacpp.indexer.LongRawIndexer
Please follow the instructions on http://deeplearning4j.org/android they will work. If you're unable to make it work though, please wait until the next release.
I take code from http://deeplearning4j.org/android and change all 1.0.0-beta2 to 1.0.0-SNAPSHOT but there's dependency error(The error i said before). Note: i copied pom.xml though and run mvn -U compile.
So there's no way to make my app work now? And the next release is for when?
You will also need to include
mavenLocal()in therepository {}block of the build.gradle file.
It's so hard to just run an example(in android only, it works fine on linux). So today i add mavenLocal(), as you said. I run mvn -U compile
and there's i new error
[ERROR] Failed to execute goal on project snapshots: Could not resolve dependencies for project org.deeplearning4j:snapshots:jar:1.0.0-SNAPSHOT: Could not find artifact org.nd4j:nd4j-native:jar:android-arm64:1.0.0-20180928.004910-6193 in sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots)
So i follow this link and see that there's is no android-arm64:1.0.0-20180928.004910-6193 but it still in metadata
@sshepel Any ideas why this is happening again? Sounds like an issue with the Nexus server...
@sshepel Yeah, we'll need to do something about this: https://issues.sonatype.org/browse/NEXUS-1615
So i need to wait until next build/deployment or something like that of the SNAPSHOT right?
@saudet I have checked links provided by @titamrtn and it looks ok for me... metadata points to latest snapshots in repository (nightly build of master):
<snapshotVersion>
<classifier>android-arm64</classifier>
<extension>jar</extension>
<value>1.0.0-20181001.004621-6231</value>
<updated>20181001004621</updated>
</snapshotVersion>
And this is the only record in metadata file.
Artifacts themselves are also in repo:

@saudet the issue that you provided is really old, of course it could be a chance that it still there, but or oss.nexus update's artifact metadata really slow, but I don't think so. Will check metadata tomorrow after nightly build.
Link to the build log for October 1st: https://jenkins.ci.skymind.io/blue/organizations/jenkins/deeplearing4j%2Fdeeplearning4j/detail/master/153/pipeline/50#step-537-log-903
@titamrtn it's not necessary to wait next build, as workaround you can try to fetch required artifacts for oss.nexus and install it manually (more details here: https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html), or check you local repo, looks like it didn't pick latest snapshots...
@sshepel It's usually OK, it just happens sometimes.
Thanks, now it work.
Failed to resolve: nd4j-native-android-arm
Failed to resolve: nd4j-native-android-arm64
Failed to resolve: nd4j-native-android-x86
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not find opencv-android-x86_64.jar (org.bytedeco.javacpp-presets:opencv:3.4.3-1.4.3-SNAPSHOT).
<a href="openFile:/home/ailton/AndroidStudioProjects/ConvertToGray/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not find opencv-android-x86_64.jar (org.bytedeco.javacpp-presets:opencv:3.4.3-1.4.3-SNAPSHOT).">Show Details</a>
Unable to resolve dependency for ':app@debug/compileClasspath': Could not find nd4j-native-android-x86_64.jar (org.nd4j:nd4j-native:1.0.0-SNAPSHOT).
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not find nd4j-native-android-x86_64.jar (org.nd4j:nd4j-native:1.0.0-SNAPSHOT).
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not find nd4j-native-android-x86_64.jar (org.nd4j:nd4j-native:1.0.0-SNAPSHOT).
Unable to resolve dependency for ':app@release/compileClasspath': Could not find nd4j-native-android-x86_64.jar (org.nd4j:nd4j-native:1.0.0-SNAPSHOT).
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not find nd4j-native-android-x86_64.jar (org.nd4j:nd4j-native:1.0.0-SNAPSHOT).
hello @titamrtn , I'm with this same problem, how did you solve it?
@AILTON091 I've just tried it again to make sure nothing broke, and I'm still not seeing any issues. I've put the pom.xml file from https://deeplearning4j.org/android in my project directory, called mvn -U compile on it, and built with following in the app/gradle.build file:
repositories {
mavenLocal()
}
dependencies {
compile (group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '1.0.0-SNAPSHOT') {
exclude group: 'org.bytedeco.javacpp-presets', module: 'opencv-platform'
exclude group: 'org.bytedeco.javacpp-presets', module: 'leptonica-platform'
exclude group: 'org.bytedeco.javacpp-presets', module: 'hdf5-platform'
}
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-arm"
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-arm64"
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-x86"
compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-x86_64"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.3-1.4.3-SNAPSHOT'
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.3-1.4.3-SNAPSHOT', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.3-1.4.3-SNAPSHOT', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.3-1.4.3-SNAPSHOT', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.3-1.4.3-SNAPSHOT', classifier: "android-x86_64"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3-SNAPSHOT'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3-SNAPSHOT', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3-SNAPSHOT', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3-SNAPSHOT', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3-SNAPSHOT', classifier: "android-x86_64"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.3-SNAPSHOT'
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.3-SNAPSHOT', classifier: "android-arm"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.3-SNAPSHOT', classifier: "android-arm64"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.3-SNAPSHOT', classifier: "android-x86"
compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.3-SNAPSHOT', classifier: "android-x86_64"
// ...
}
@agibsonccc @saudet I made the same changes to your glade but when I click sync it gives me this error
Error:Failed to resolve: org.deeplearning4j:deeplearning4j-core:1.0.0-SNAPSHOT
Error:Failed to resolve: org.nd4j:nd4j-native:1.0.0-SNAPSHOT
Error:Failed to resolve: org.bytedeco.javacpp-presets:openblas:0.3.3-1.4.3-SNAPSHOT
Error:Failed to resolve: org.bytedeco.javacpp-presets:opencv:3.4.3-1.4.3-SNAPSHOT
Error:Failed to resolve: org.bytedeco.javacpp-presets:leptonica:1.76.0-1.4.3-SNAPSHOT
and when run the error run -U compile command too
[ERROR] Failed to execute goal on project snapshots: Could not resolve dependencies for project org.deeplearning4j:snapshots:jar:1.0.0-SNAPSHOT: The following artifacts could not be resolved: org.slf4j:slf4j-api:jar:1.7.21, org.bytedeco.javacpp-presets:leptonica:jar:windows-x86:1.76.0-1.4.3-SNAPSHOT: Could not transfer artifact org.slf4j:slf4j-api:jar:1.7.21 from/to central (https://repo.maven.apache.org/maven2): Tempo esgotado para conex茫o (Read failed) -> [Help 1]
@saudet @titamrtn I am trying to run the given Iris Classifier example on android followed by the instruction, but I got an error during building by android studio.
Actually, I put the pom.xml into the root directory and did the mvn -U compile, and everything is good on my Macbook Pro. I also changed all beta2 to the 1.0.0-SNAPSHOT.
Here is the issue:
/Users/zhangyu/Documents/TensorFlow/dl4jZac/app/build/intermediates/transforms/dexBuilder/debug/151.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: org.nd4j.serde.base64.Nd4jBase64
at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:132)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:117)
at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:101)
at com.android.build.gradle.internal.transforms.ExternalLibsMergerTransform.transform(ExternalLibsMergerTransform.kt:122)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
... 124 more
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:65)
at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:43)
at com.android.tools.r8.D8.run(D8.java:90)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:115)
... 129 more
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: org.nd4j.serde.base64.Nd4jBase64
at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:116)
at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:74)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:59)
... 132 more
It seems this issue caused by the duplicate classes, and it said Error: Program type already present: org.nd4j.serde.base64.Nd4jBase64, but I applied the multiDexEnabled true.
So, could you please help me out? Many thanks for that.
And here is my app/gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/INDEX.LIST'
}
}
repositories {
// maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
// mavenCentral()
mavenLocal()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.google.code.gson:gson:2.8.2'
annotationProcessor 'org.projectlombok:lombok:1.16.16'
implementation 'com.google.code.findbugs:annotations:3.0.1', {
exclude module: 'jsr305'
exclude module: 'jcip-annotations'
}
implementation(group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '1.0.0-SNAPSHOT') {
exclude group: 'org.bytedeco.javacpp-presets', module: 'opencv-platform'
exclude group: 'org.bytedeco.javacpp-presets', module: 'leptonica-platform'
exclude group: 'org.bytedeco.javacpp-presets', module: 'hdf5-platform'
}
implementation group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT'
implementation group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-arm"
implementation group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-arm64"
implementation group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-x86"
implementation group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-SNAPSHOT', classifier: "android-x86_64"
implementation group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.3-1.4.3-SNAPSHOT'
implementation group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.3-1.4.3-SNAPSHOT', classifier: "android-arm"
implementation group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.3-1.4.3-SNAPSHOT', classifier: "android-arm64"
implementation group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.3-1.4.3-SNAPSHOT', classifier: "android-x86"
implementation group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.3-1.4.3-SNAPSHOT', classifier: "android-x86_64"
implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3-SNAPSHOT'
implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3-SNAPSHOT', classifier: "android-arm"
implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3-SNAPSHOT', classifier: "android-arm64"
implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3-SNAPSHOT', classifier: "android-x86"
implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3-SNAPSHOT', classifier: "android-x86_64"
implementation group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.3-SNAPSHOT'
implementation group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.3-SNAPSHOT', classifier: "android-arm"
implementation group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.3-SNAPSHOT', classifier: "android-arm64"
implementation group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.3-SNAPSHOT', classifier: "android-x86"
implementation group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.3-SNAPSHOT', classifier: "android-x86_64"
//This corrects for a junit version conflict.
configurations.all {
resolutionStrategy.force 'junit:junit:4.12'
}
}
}
@zhangy10 1.0.0-beta3 has been released, try with that! Thanks. Note that you'll need to add exclude group: 'org.nd4j', module: 'nd4j-base64' to work around that known issue.
@saudet Thanks so much for that and now it works!
@AILTON091 Please open another issue if you're still having problems with 1.0.0-beta3, thanks!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@sshepel It's usually OK, it just happens sometimes.