Closed Suceru closed 4 years ago
Hi @Suceru, I will get back to you as soon as I have access to a Windows computer as I'm currently abroad!
Hi @Suceru! I've added instructions for Windows in the README. Could you try it and see if there's anything missing or not working?
@veeableful Ok,thanks,According to the above method, there is no problem
in compiling libexample.so
.
I modified:
CC=armv7a-linux-androideabi29-clang CGO_CFLAGS="-D__ANDROID_API__=29 -I${ANDROID_NDK_HOME}/sysroot/usr/include -I${ANDROID_NDK_HOME}/sysroot/usr/include/arm-linux-androideabi --sysroot=${ANDROID_SYSROOT}" CGO_LDFLAGS="-L${ANDROID_NDK_HOME}/sysroot/usr/lib -L${ANDROID_NDK_HOME}/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/ --sysroot=${ANDROID_SYSROOT}" CGO_ENABLED=1 GOOS=android GOARCH=arm go build -tags static -buildmode=c-shared -ldflags="-s -w -extldflags=-Wl,-soname,libexample.so" -o=android/libs/armeabi-v7a/libexample.so
Then, I change:
android {
compileSdkVersion 29
buildToolsVersion '29.0.3'defaultConfig { applicationId "com.example.android" minSdkVersion 16 targetSdkVersion 29 versionCode 1 versionName '1.0' } ...
}
But i had trouble running ./gradlew
,the exported apk failed to run on Android 10
.
Maybe it's my problem, I will try again later.
$ ./gradlew assembleDebug
Task :android:checkDebugClasspath Task :android:preBuild UP-TO-DATE Task :android:preDebugBuild Task :android:compileDebugAidl NO-SOURCE Task :android:compileDebugRenderscript Task :android:checkDebugManifest Task :android:generateDebugBuildConfig Task :android:prepareLintJar Task :android:mainApkListPersistenceDebug Task :android:generateDebugResValues Task :android:generateDebugResources Task :android:mergeDebugResources Task :android:createDebugCompatibleScreenManifests Task :android:processDebugManifest Task :android:splitsDiscoveryTaskDebug Task :android:processDebugResources Task :android:generateDebugSources Task :android:javaPreCompileDebug
Task :android:compileDebugJavaWithJavac ▒▒▒▒: [options] Դֵ7▒ѹ▒ʱ, ▒▒▒▒δ▒▒▒▒▒з▒▒а▒▒▒ɾ▒▒ ▒▒▒▒: [options] Ŀ▒▒ֵ7▒ѹ▒ʱ, ▒▒▒▒δ▒▒▒▒▒з▒▒а▒▒▒ɾ▒▒ ▒▒▒▒: [options] Ҫ▒▒▒▒▒й▒▒ѹ▒ʱѡ▒▒ľ▒▒▒, ▒▒ʹ▒▒ -Xlint:-options▒▒ ע: ijЩ▒▒▒▒▒ļ▒ʹ▒û▒▒▒▒ѹ▒ʱ▒▒ API▒▒ ע: ▒й▒▒▒ϸ▒▒Ϣ, ▒▒ʹ▒▒ -Xlint:deprecation ▒▒▒±▒▒롣 ע: ijЩ▒▒▒▒▒ļ▒ʹ▒▒▒▒δ▒▒▒▒▒▒ȫ▒IJ▒▒▒▒▒ ע: ▒й▒▒▒ϸ▒▒Ϣ, ▒▒ʹ▒▒ -Xlint:unchecked ▒▒▒±▒▒롣 3 ▒▒▒▒▒▒
Task :android:compileDebugNdk NO-SOURCE Task :android:compileDebugSources Task :android:mergeDebugShaders Task :android:compileDebugShaders Task :android:generateDebugAssets Task :android:mergeDebugAssets Task :android:transformClassesWithDexBuilderForDebug Task :android:transformDexArchiveWithExternalLibsDexMergerForDebug Task :android:transformDexArchiveWithDexMergerForDebug Task :android:mergeDebugJniLibFolders Task :android:transformNativeLibsWithMergeJniLibsForDebug
Task :android:transformNativeLibsWithStripDebugSymbolForDebug D:\Android\android-ndk-r21\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-strip:C:\Users\fidax\go\src\github.com\veandco\go-sdl2.go-sdl2-examples\examples\android\android\build\intermediates\transforms\mergeJniLibs\debug\0\lib\armeabi-v7a\libexample.so: File format not recognized
Unable to strip library '1' due to error D:\Android\android-ndk-r21\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-strip returned from 'C:\Users\fidax\go\src\github.com\veandco\go-sdl2.go-sdl2-examples\examples\android\android\build\intermediates\transforms\mergeJniLibs\debug\0\lib\armeabi-v7a\libexample.so', packaging it as is.
Task :android:checkDebugLibraries Task :android:processDebugJavaRes NO-SOURCE Task :android:transformResourcesWithMergeJavaResForDebug Task :android:validateSigningDebug Task :android:packageDebug Task :android:assembleDebug
BUILD SUCCESSFUL in 5s 28 actionable tasks: 28 executed
fidax@DESKTOP-3LHFMHN MINGW64 ~/go/src/github.com/veandco/go-sdl2/.go-sdl2-examples/examples/android ((4298a58...)) $ ./gradlew assembleDebug
Task :android:checkDebugClasspath UP-TO-DATE Task :android:preBuild UP-TO-DATE Task :android:preDebugBuild UP-TO-DATE Task :android:compileDebugAidl NO-SOURCE Task :android:compileDebugRenderscript UP-TO-DATE Task :android:checkDebugManifest UP-TO-DATE Task :android:generateDebugBuildConfig UP-TO-DATE Task :android:prepareLintJar UP-TO-DATE Task :android:mainApkListPersistenceDebug UP-TO-DATE Task :android:generateDebugResValues UP-TO-DATE Task :android:generateDebugResources UP-TO-DATE Task :android:mergeDebugResources UP-TO-DATE Task :android:createDebugCompatibleScreenManifests UP-TO-DATE Task :android:processDebugManifest UP-TO-DATE Task :android:splitsDiscoveryTaskDebug UP-TO-DATE Task :android:processDebugResources UP-TO-DATE Task :android:generateDebugSources UP-TO-DATE Task :android:javaPreCompileDebug UP-TO-DATE Task :android:compileDebugJavaWithJavac UP-TO-DATE Task :android:compileDebugNdk NO-SOURCE Task :android:compileDebugSources UP-TO-DATE Task :android:mergeDebugShaders UP-TO-DATE Task :android:compileDebugShaders UP-TO-DATE Task :android:generateDebugAssets UP-TO-DATE Task :android:mergeDebugAssets UP-TO-DATE Task :android:transformClassesWithDexBuilderForDebug UP-TO-DATE Task :android:transformDexArchiveWithExternalLibsDexMergerForDebug UP-TO-DATE Task :android:transformDexArchiveWithDexMergerForDebug UP-TO-DATE Task :android:mergeDebugJniLibFolders UP-TO-DATE Task :android:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE Task :android:transformNativeLibsWithStripDebugSymbolForDebug UP-TO-DATE Task :android:checkDebugLibraries UP-TO-DATE Task :android:processDebugJavaRes NO-SOURCE Task :android:transformResourcesWithMergeJavaResForDebug UP-TO-DATE Task :android:validateSigningDebug UP-TO-DATE Task :android:packageDebug UP-TO-DATE Task :android:assembleDebug UP-TO-DATE
BUILD SUCCESSFUL in 1s 28 actionable tasks: 28 up-to-date
Hi @Suceru, is there a reason you needed to modify the build command? For me, it worked fine on my Android 10 device as it is.
@veeableful I only downloaded the android API29 SDK on my computer, and I didn't know how to choose it, so I chose the latest installation.If it's a modification, I'll try to get back down to api16 tomorrow.
Ahh okay. I think if you target a minimum of API 16, it would be better in the sense that it can be installed on more devices that has Android 4.1 to Android 10 (as far as I know!).
@veeableful Okay, I know what the reason is. At first, the envirinment variables
I compiled wre not set correctly. I set a %Path%
less in the environment variable Path
.
Now it runs successfully.
Thank you very much!!
Oh that's good to hear! I'm glad you managed to get it running. And no problem :smiley:
How to use
go-sdl2-examples\examples\android
examples on Windows platform. Is how to compile SDL2 onWindows10 platform
toAPK file
. The originalREADME
was forLinux
, I don't know how to put it inWindows10
. Thank you!