1, new project, do not select Include support C + +
2. New Folder CPP, put the. cpp file in it;
3, write the JNI interface file, note that the function name prefix in the file should be consistent with the applicationid of Build.gradle under the app;
4, write CMakeLists.txt, in View->tool windows->gradle->build generate. So file
Errors encountered at compile time
(1)error:execution failed for task ': App:transformclasseswithdexfordebug '.
> com.android.build.api.transform.TransformException:java.lang.RuntimeException: Com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException: Com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:Process ' command ' C + Program Files\java\jdk1.7.0_67\bin\java.exe "finished with Non-zero exit value 1
Workaround: Add Defaultconfig under Builder.gradle under app {
.....
multidexenabled true
.....
}
(2) failed for Task .> Java.. Zip. Zipexception: duplicate Entry: android< Span class= "pun" >/support/v4/ util/timeutils.
Workaround: Add under Build.gradle under app:
Android{ configurations { All* . exclude group: Com.android.support ' , module: ' support-v4 ' All*.group: ' Com.android.support ' Span class= "pun" >, module: } }
Reference: https://stackoverflow.com/questions/26966843/ Java-util-zip-zipexception-duplicate-entry-during-packagealldebugclassesformult
Call C + + files in Android and switch to so