Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it's unable to build using NDK 18.1.* #82

Open
lyricssorceress opened this issue Oct 21, 2018 · 3 comments
Open

it's unable to build using NDK 18.1.* #82

lyricssorceress opened this issue Oct 21, 2018 · 3 comments

Comments

@lyricssorceress
Copy link

After changing APP_STL := c++_static, the error information goes as follows: (please help me out, thanks) 1 warnings & 2 errors.

Build command failed.
Error while executing process /Users/lc/Library/Android/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/src/main/jni/Android.mk NDK_APPLICATION_MK=/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/src/main/jni/Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/build/intermediates/ndkBuild/debug/lib /Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/build/intermediates/ndkBuild/debug/obj/local/armeabi-v7a/libva++.so}
Android NDK: WARNING:/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/src/main/jni/fb/Android.mk:fb: LOCAL_LDLIBS is always ignored for static libraries
[armeabi-v7a] Compile++ thumb: va++ <= SubstrateHook.cpp
/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/src/main/jni/Substrate/SubstrateHook.cpp:124:100: warning: '&&' within '||' [-Wlogical-op-parentheses]
return (ic[0] & 0xf800) == 0xf000 && ((ic[1] & 0xd000) == 0x9000 || (ic[1] & 0xd000) == 0x8000 && (ic[0] & 0x0380) != 0x0380);
~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/src/main/jni/Substrate/SubstrateHook.cpp:124:100: note: place parentheses around the '&&' expression to silence this warning
return (ic[0] & 0xf800) == 0xf000 && ((ic[1] & 0xd000) == 0x9000 || (ic[1] & 0xd000) == 0x8000 && (ic[0] & 0x0380) != 0x0380);
^
( )
/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/src/main/jni/Substrate/SubstrateHook.cpp:463:31: error: call to 'abs' is ambiguous
buffer[start+1] = T2$ldr_rt_$rn_im$(exts.rt, A$pc, T$Label(start+0, end-2));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/src/main/jni/Substrate/SubstrateHook.cpp:93:21: note: expanded from macro 'T2$ldr_rt_$rn_im$'
(((rt) << 12) | abs(im))
^~~
/Users/lc/Library/Android/sdk/ndk-bundle/sysroot/usr/include/stdlib.h:230:5: note: candidate function
int abs(int __x) attribute_const __INTRODUCED_IN(19);
^
/Users/lc/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/stdlib.h:111:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
^
/Users/lc/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/stdlib.h:113:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(x);}
^
/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/src/main/jni/Substrate/SubstrateHook.cpp:647:31: error: call to 'abs' is ambiguous
buffer[start+0] = A$ldr_rd
$rn_im$(copy.rn, A$pc, (end-1 - (start+0)) * 4 - 8);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/src/main/jni/Substrate/SubstrateARM.hpp:49:76: note: expanded from macro 'A$ldr_rd
$rn_im$'
(0xe5100000 | ((im) < 0 ? 0 : 1 << 23) | ((rn) << 16) | ((rd) << 12) | abs(im))
^~~
/Users/lc/Library/Android/sdk/ndk-bundle/sysroot/usr/include/stdlib.h:230:5: note: candidate function
int abs(int __x) attribute_const __INTRODUCED_IN(19);
^
/Users/lc/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/stdlib.h:111:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
^
/Users/lc/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/stdlib.h:113:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
^
1 warning and 2 errors generated.
make: *** [/Users/lc/StudioProjects/VirtualHook/VirtualApp/lib/build/intermediates/ndkBuild/debug/obj/local/armeabi-v7a/objs/va++/Substrate/SubstrateHook.o] Error 1

@rk700
Copy link
Member

rk700 commented Oct 22, 2018

Not quite sure but maybe the code of VirtualApp is outdated.

@rk700
Copy link
Member

rk700 commented Dec 20, 2018

Should be fixed in 5b67a32 by defining a custom abs

@chk007
Copy link

chk007 commented Jan 9, 2019

I got the same problem, and solved it by modifying all the abs() to labs(). My git diff file is as following:


diff --git a/VirtualApp/app/build.gradle b/VirtualApp/app/build.gradle
index 6fee2f9..f87ef87 100644
--- a/VirtualApp/app/build.gradle
+++ b/VirtualApp/app/build.gradle
@@ -3,11 +3,11 @@ apply plugin: 'com.android.application'
 
 android {
     compileSdkVersion 26
-    buildToolsVersion '26.0.2'
+    buildToolsVersion '28.0.2'
     defaultConfig {
         applicationId "io.virtualapp"
         minSdkVersion 15
-        targetSdkVersion 22
+        targetSdkVersion 26
         versionCode 24
         versionName "1.2.5"
         multiDexEnabled true
diff --git a/VirtualApp/lib/build.gradle b/VirtualApp/lib/build.gradle
index 6008db5..152b7af 100644
--- a/VirtualApp/lib/build.gradle
+++ b/VirtualApp/lib/build.gradle
@@ -2,17 +2,17 @@ apply plugin: 'com.android.library'
 
 android {
     compileSdkVersion 26
-    buildToolsVersion '26.0.2'
-
+    buildToolsVersion '28.0.2'
     defaultConfig {
-        minSdkVersion 14
-        targetSdkVersion 22
+        minSdkVersion 15
+        targetSdkVersion 26
         versionCode 1
         versionName "1.0"
-        externalNativeBuild {
-            ndkBuild {
-                abiFilters "armeabi-v7a", "x86"
-            }
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+        ndk {
+            // Specifies the ABI configurations of your native
+            // libraries Gradle should build and package with your APK.
+            abiFilters 'armeabi-v7a', 'x86'
         }
     }
     buildTypes {
@@ -23,16 +23,17 @@ android {
     }
     externalNativeBuild {
         ndkBuild {
-            path file("src/main/jni/Android.mk")
+            path 'src/main/jni/Android.mk'
         }
     }
-    lintOptions {
-        //IJobService need NewApi
-        warning 'NewApi','OnClick'
+    productFlavors {
     }
 }
 
-
 dependencies {
-    compile fileTree(include: ['*.jar'], dir: 'libs')
-}
+    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'
+    })
+    androidTestImplementation 'junit:junit:4.12'
+}
\ No newline at end of file
diff --git a/VirtualApp/lib/src/main/jni/Application.mk b/VirtualApp/lib/src/main/jni/Application.mk
index 7ec75bd..0e53eba 100644
--- a/VirtualApp/lib/src/main/jni/Application.mk
+++ b/VirtualApp/lib/src/main/jni/Application.mk
@@ -1,6 +1,6 @@
 APP_ABI := armeabi-v7a x86
 APP_PLATFORM := android-14
-APP_STL := gnustl_static
+APP_STL := c++_static
 APP_OPTIM := release
 VA_ROOT          := $(call my-dir)
 NDK_MODULE_PATH  := $(NDK_MODULE_PATH):$(VA_ROOT)
\ No newline at end of file
diff --git a/VirtualApp/lib/src/main/jni/Substrate/SubstrateARM.hpp b/VirtualApp/lib/src/main/jni/Substrate/SubstrateARM.hpp
index 7dd3139..09bda99 100755
--- a/VirtualApp/lib/src/main/jni/Substrate/SubstrateARM.hpp
+++ b/VirtualApp/lib/src/main/jni/Substrate/SubstrateARM.hpp
@@ -46,7 +46,7 @@ enum A$c {
 #define A$msr_cpsr_f_rm(rm) /* msr cpsr_f, rm */ \
     (0xe128f000 | (rm))
 #define A$ldr_rd_$rn_im$(rd, rn, im) /* ldr rd, [rn, #im] */ \
-    (0xe5100000 | ((im) < 0 ? 0 : 1 << 23) | ((rn) << 16) | ((rd) << 12) | abs(im))
+    (0xe5100000 | ((im) < 0 ? 0 : 1 << 23) | ((rn) << 16) | ((rd) << 12) | labs(im))
 #define A$str_rd_$rn_im$(rd, rn, im) /* sr rd, [rn, #im] */ \
     (0xe5000000 | ((im) < 0 ? 0 : 1 << 23) | ((rn) << 16) | ((rd) << 12) | abs(im))
 #define A$sub_rd_rn_$im(rd, rn, im) /* sub, rd, rn, #im */ \
diff --git a/VirtualApp/lib/src/main/jni/Substrate/SubstrateHook.cpp b/VirtualApp/lib/src/main/jni/Substrate/SubstrateHook.cpp
index 34f2a26..e13636a 100755
--- a/VirtualApp/lib/src/main/jni/Substrate/SubstrateHook.cpp
+++ b/VirtualApp/lib/src/main/jni/Substrate/SubstrateHook.cpp
@@ -90,7 +90,7 @@ X 4790  ldr r*,[pc,#*]    */
 #define T1$ldr_rt_$rn_im$(rt, rn, im) /* ldr rt, [rn, #im] */ \
     (0xf850 | ((im < 0 ? 0 : 1) << 7) | (rn))
 #define T2$ldr_rt_$rn_im$(rt, rn, im) /* ldr rt, [rn, #im] */ \
-    (((rt) << 12) | abs(im))
+    (((rt) << 12) | labs(im))
 
 #define T1$mrs_rd_apsr(rd) /* mrs rd, apsr */ \
     (0xf3ef)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants