diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 8cf93266..dd35ce2b 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -1,54 +1,8 @@
-# For more information about using CMake with Android Studio, read the
-# documentation: https://d.android.com/studio/projects/add-native-code.html
+cmake_minimum_required (VERSION 3.2)
+project(LightSwitch VERSION 1 LANGUAGES CXX)
+set_property(GLOBAL PROPERTY CMAKE_CXX_STANDARD 17 PROPERTY CMAKE_CXX_STANDARD_REQUIRED TRUE)
-# Sets the minimum version of CMake required to build the native library.
-
-cmake_minimum_required(VERSION 3.4.1)
-
-set(unicorn_DIR ${CMAKE_SOURCE_DIR}/src/main/cpp/unicorn)
-
-include_directories(${unicorn_DIR}/lib/${ANDROID_ABI}/include)
-
-add_library(unicorn SHARED IMPORTED)
-set_target_properties(unicorn PROPERTIES IMPORTED_LOCATION
- ${unicorn_DIR}/lib/${ANDROID_ABI}/libunicorn.so)
-
-# Creates and names a library, sets it as either STATIC
-# or SHARED, and provides the relative paths to its source code.
-# You can define multiple libraries, and CMake builds them for you.
-# Gradle automatically packages shared libraries with your APK.
-
-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)
-
-# Searches for a specified prebuilt library and stores the path as a
-# variable. Because CMake includes system libraries in the search path by
-# default, you only need to specify the name of the public NDK library
-# you want to add. CMake verifies that the library exists before
-# completing its build.
-
-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)
-
-# Specifies libraries CMake should link to your target library. You
-# can link multiple libraries, such as libraries you define in this
-# build script, prebuilt third-party libraries, or system libraries.
-
-target_link_libraries( # Specifies the target library.
- native-lib
-
- unicorn
-
- # Links the target library to the log library
- # included in the NDK.
- ${log-lib})
\ No newline at end of file
+set(source_DIR ${CMAKE_SOURCE_DIR}/src/main/cpp/)
+include_directories(${source_DIR}include/)
+add_library(lightswitch SHARED ${source_DIR}lightswitch.cpp)
+target_link_libraries(lightswitch ${source_DIR}/lib/${ANDROID_ABI}/libunicorn.a)
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index d6975805..2d602304 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -9,7 +9,6 @@ android {
targetSdkVersion 29
versionCode 1
versionName "1.0"
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
@@ -28,7 +27,6 @@ android {
externalNativeBuild {
cmake {
path "CMakeLists.txt"
- version "3.10.2"
}
}
sourceSets {
@@ -42,7 +40,4 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test:runner:1.2.0'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
diff --git a/app/src/androidTest/java/gq/cyuubi/lightswitch/ExampleInstrumentedTest.java b/app/src/androidTest/java/gq/cyuubi/lightswitch/ExampleInstrumentedTest.java
deleted file mode 100644
index eebc10c1..00000000
--- a/app/src/androidTest/java/gq/cyuubi/lightswitch/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package gq.cyuubi.lightswitch;
-
-import android.content.Context;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("gq.cyuubi.lightswitch", appContext.getPackageName());
- }
-}
diff --git a/app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/arm.h b/app/src/main/cpp/include/unicorn/arm.h
similarity index 100%
rename from app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/arm.h
rename to app/src/main/cpp/include/unicorn/arm.h
diff --git a/app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/arm64.h b/app/src/main/cpp/include/unicorn/arm64.h
similarity index 100%
rename from app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/arm64.h
rename to app/src/main/cpp/include/unicorn/arm64.h
diff --git a/app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/m68k.h b/app/src/main/cpp/include/unicorn/m68k.h
similarity index 100%
rename from app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/m68k.h
rename to app/src/main/cpp/include/unicorn/m68k.h
diff --git a/app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/mips.h b/app/src/main/cpp/include/unicorn/mips.h
similarity index 100%
rename from app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/mips.h
rename to app/src/main/cpp/include/unicorn/mips.h
diff --git a/app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/platform.h b/app/src/main/cpp/include/unicorn/platform.h
similarity index 100%
rename from app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/platform.h
rename to app/src/main/cpp/include/unicorn/platform.h
diff --git a/app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/sparc.h b/app/src/main/cpp/include/unicorn/sparc.h
similarity index 100%
rename from app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/sparc.h
rename to app/src/main/cpp/include/unicorn/sparc.h
diff --git a/app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/unicorn.h b/app/src/main/cpp/include/unicorn/unicorn.h
similarity index 100%
rename from app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/unicorn.h
rename to app/src/main/cpp/include/unicorn/unicorn.h
diff --git a/app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/x86.h b/app/src/main/cpp/include/unicorn/x86.h
similarity index 100%
rename from app/src/main/cpp/unicorn/lib/arm64-v8a/include/unicorn/x86.h
rename to app/src/main/cpp/include/unicorn/x86.h
diff --git a/app/src/main/cpp/lib/arm64-v8a/libunicorn.a b/app/src/main/cpp/lib/arm64-v8a/libunicorn.a
new file mode 100644
index 00000000..6f3c7da9
Binary files /dev/null and b/app/src/main/cpp/lib/arm64-v8a/libunicorn.a differ
diff --git a/app/src/main/cpp/native-lib.cpp b/app/src/main/cpp/lightswitch.cpp
similarity index 100%
rename from app/src/main/cpp/native-lib.cpp
rename to app/src/main/cpp/lightswitch.cpp
diff --git a/app/src/main/cpp/unicorn/lib/arm64-v8a/libunicorn.so b/app/src/main/cpp/unicorn/lib/arm64-v8a/libunicorn.so
deleted file mode 100644
index bd51d322..00000000
Binary files a/app/src/main/cpp/unicorn/lib/arm64-v8a/libunicorn.so and /dev/null differ
diff --git a/app/src/main/java/gq/cyuubi/lightswitch/MainActivity.java b/app/src/main/java/gq/cyuubi/lightswitch/MainActivity.java
index fbf47cb1..ed231c22 100644
--- a/app/src/main/java/gq/cyuubi/lightswitch/MainActivity.java
+++ b/app/src/main/java/gq/cyuubi/lightswitch/MainActivity.java
@@ -1,15 +1,14 @@
package gq.cyuubi.lightswitch;
-import androidx.appcompat.app.AppCompatActivity;
-
import android.os.Bundle;
import android.widget.TextView;
+import androidx.appcompat.app.AppCompatActivity;
+
public class MainActivity extends AppCompatActivity {
- // Used to load the 'native-lib' library on application startup.
static {
- System.loadLibrary("native-lib");
+ System.loadLibrary("lightswitch");
}
@Override
@@ -22,9 +21,5 @@ public class MainActivity extends AppCompatActivity {
tv.setText(stringFromJNI());
}
- /**
- * A native method that is implemented by the 'native-lib' native library,
- * which is packaged with this application.
- */
public native String stringFromJNI();
}
diff --git a/app/src/test/java/gq/cyuubi/lightswitch/ExampleUnitTest.java b/app/src/test/java/gq/cyuubi/lightswitch/ExampleUnitTest.java
deleted file mode 100644
index f8256cfe..00000000
--- a/app/src/test/java/gq/cyuubi/lightswitch/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package gq.cyuubi.lightswitch;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 02199bb8..78fbc17a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,11 +4,11 @@ buildscript {
repositories {
google()
jcenter()
-
+
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
-
+
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
@@ -18,7 +18,7 @@ allprojects {
repositories {
google()
jcenter()
-
+
}
}