qt icon indicating copy to clipboard operation
qt copied to clipboard

Android x86_64 and Android Arm_64 qtdeploy does not exist

Open omac777 opened this issue 7 years ago • 4 comments

Android-x86 7.1-r1 live and installation iso (64-bit)

http://www.android-x86.org
https://osdn.net/projects/android-x86/downloads/67834/android-x86_64-7.1-r1.iso

I was getting build errors for the androidextras from within the internal directory so I decided to move them out to another directory and the build was successful from there. mv therecipe/qt/internal/examples/androidextras/ omac777/

Building the two apks for jni and notification with:

cd omac777/androidextras/notification/
qtdeploy -docker build android .
cd omac777/androidextras/jni/
qtdeploy -docker build android .

From within the Android-x86 VirtualBox, I didn't have shared folders access, but I circumvented the issue by installing vdfuse. I mounted the vdi and copied the two apks into the Downloads directory within Android-X86:

pacaur -S aur/vdfuse
mkdir myAndroidVDI
vdfuse -a -f /home/dma2/VirtualBox\ VMs/droid71x8664/droid71x8664.vdi /mnt/myAndroidVDI/
mkdir myAndroidEntireDiskLoop
mount -o loop /mnt/myAndroidVDI/Partition1 /mnt/myAndroidEntireDiskLoop
cp /home/dma2/Downloads/sharewithapkinstaller/gostagetools.apk ./data/media/0/Download/
umount /mnt/myAndroidEntireDiskLoop/
umount /mnt/myAndroidVDI/

After all this, I got runtime exceptions because I determined the binaries built were for arm32-bit.

My change request is to add a few more build configurations: 1)64-bit arm android build target 2)64-bit x86 android build target

Thank you.

omac777 avatar Feb 13 '18 18:02 omac777

OK so I decided to take another approach and see if I could see the built android apk would run on armv7 android. Actually it does. Surprisingly the very same apk ALSO runs on armv8 android without modifications.

qtdeploy -docker build android .
mv build-debug.apk gojni.apk
mv gojni.apk /home/dma2/Downloads/sharewithapkinstaller/
mv build-debug.apk gonotification.apk
mv gonotification.apk /home/dma2/Downloads/sharewithapkinstaller/
vdfuse -a -f /home/dma2/VirtualBox\ VMs/droid71x8664/droid71x8664.vdi /mnt/myAndroidVDI/
mount -o loop /mnt/myAndroidVDI/Partition1 /mnt/myAndroidEntireDiskLoop
cp /home/dma2/Downloads/sharewithapkinstaller/gojni.apk /mnt/myAndroidEntireDiskLoop/android-7.1-r1/data/media/0/Download/
chown 1023:1023 gojni.apk 
chmod g+w gojni.apk 
cp /home/dma2/Downloads/sharewithapkinstaller/gonotification.apk /mnt/myAndroidEntireDiskLoop/android-7.1-r1/data/media/0/Download/
chown 1023:1023 gonotification.apk 
chmod g+w gonotification.apk 
umount /mnt/myAndroidEntireDiskLoop/
umount /mnt/myAndroidVDI/
pacman -S android-sdk-platform-tools android-sdk android-platform android-sdk-build-tools
export ANDROID_HOME=/opt/android-sdk
export ANDROID_AVD_HOME=/root/.android/avd
export PATH=/opt/android-sdk/platform-tools:/opt/android-sdk/emulator:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:$PATH
usermod -a -G sdkusers dma2
cd .android/
touch repositories.cfg
cd /opt/android-sdk/tools/bin
./sdkmanager 
./sdkmanager --install ndk-bundle
./sdkmanager --install emulator
./sdkmanager --install "system-images;android-24;default;arm64-v8a"
./sdkmanager --install "platforms;android-24" "build-tools;24.0.3" "system-images;android-24;default;x86_64" "system-images;android-24;default;armeabi-v7a"
avdmanager create avd --name "myadk24arm" -k "system-images;android-24;default;armeabi-v7a" -d 1
avdmanager create avd --name "myadk24x8664" -k "system-images;android-24;default;x86_64" -d 1
avdmanager create avd --name "myadk24arm64" -k "system-images;android-24;default;arm64-v8a" -d 1
emulator -list-avds
emulator -avd myadk24arm
emulator -avd myadk24x8664
emulator -avd myadk24arm -gpu on -memory 4096
emulator -avd myadk24arm -gpu on -memory 4096 -verbose

omac777 avatar Feb 14 '18 14:02 omac777

Within qt/internal/cmd/cmd.go, the function with signature: func BuildEnv(target, name, depPath string) (map[string]string, []string, []string, string)

places android generates only armv7 binaries

case "android":
		tags = []string{target}
		ldFlags = []string{"-s", "-w"}
		out = filepath.Join(depPath, "libgo_base.so")
		env = map[string]string{
			"PATH":   os.Getenv("PATH"),
			"GOPATH": utils.GOPATH(),
			"GOROOT": runtime.GOROOT(),

			"GOOS":   "android",
			"GOARCH": "arm",
			"GOARM":  "7",

			"CGO_ENABLED":  "1",
			"CC":           filepath.Join(utils.ANDROID_NDK_DIR(), "toolchains", "arm-linux-androideabi-4.9", "prebuilt", runtime.GOOS+"-x86_64", "bin", "arm-linux-androideabi-gcc"),
			"CXX":          filepath.Join(utils.ANDROID_NDK_DIR(), "toolchains", "arm-linux-androideabi-4.9", "prebuilt", runtime.GOOS+"-x86_64", "bin", "arm-linux-androideabi-g++"),
			"CGO_CPPFLAGS": fmt.Sprintf("-isystem %v", filepath.Join(utils.ANDROID_NDK_DIR(), "platforms", "android-16", "arch-arm", "usr", "include")),
			"CGO_LDFLAGS":  fmt.Sprintf("--sysroot=%v -llog", filepath.Join(utils.ANDROID_NDK_DIR(), "platforms", "android-16", "arch-arm")),
		}

Oddly enough the ios targets have arm64 which is equivalent to armv8.

	case "ios", "ios-simulator":
		tags = []string{"ios"}
		ldFlags = []string{"-w"}
		out = filepath.Join(depPath, "libgo.a")

		GOARCH := "amd64"
		CLANGDIR := "iPhoneSimulator"
		CLANGPLAT := utils.IPHONESIMULATOR_SDK_DIR()
		CLANGFLAG := "ios-simulator"
		CLANGARCH := "x86_64"
		if target == "ios" {
			GOARCH = "arm64"
			CLANGDIR = "iPhoneOS"
			CLANGPLAT = utils.IPHONEOS_SDK_DIR()
			CLANGFLAG = "iphoneos"
			CLANGARCH = "arm64"
		}

		env = map[string]string{
			"PATH":   os.Getenv("PATH"),
			"GOPATH": utils.GOPATH(),
			"GOROOT": runtime.GOROOT(),

			"GOOS":   runtime.GOOS,
			"GOARCH": GOARCH,

			"CGO_ENABLED":  "1",
			"CGO_CPPFLAGS": fmt.Sprintf("-isysroot %v/Contents/Developer/Platforms/%v.platform/Developer/SDKs/%v -m%v-version-min=10.0 -arch %v", utils.XCODE_DIR(), CLANGDIR, CLANGPLAT, CLANGFLAG, CLANGARCH),
			"CGO_LDFLAGS":  fmt.Sprintf("-isysroot %v/Contents/Developer/Platforms/%v.platform/Developer/SDKs/%v -m%v-version-min=10.0 -arch %v", utils.XCODE_DIR(), CLANGDIR, CLANGPLAT, CLANGFLAG, CLANGARCH),
		}

This places binaries for android at a disadvantage. I believe there should be more flexibility as to what kind of android binary the therecipe/qt bindings generate/build/deploy.

I am recommending that they follow the naming convention as used by the sdkmanager installer. i.e.

android-24;default;x86_64
android-24;default;arm64-v8a
android-24;default;armeabi-v7a

I am recommending the commandline for qtdeploy should look like this:

qtdeploy -docker build android-24;default;x86_64 .
qtdeploy -docker build android-24;arm64-v8a .
qtdeploy -docker build android-24;armeabi-v7a .

that implies the docker image has to have support for all these in one fell stroke or there should perhaps be several docker images supporting the different targets.

omac777 avatar Feb 21 '18 16:02 omac777

Hey

Yeah, specifying the android platform api version is a good idea. I will look into this, hopefully the old versions aren't to big.

Specifying the cpu architecture would work as well, but there is still the need for the pre-build Qt libs. Sadly the only pre-build versions provided by the official installer are armv7 and x86.

therecipe avatar Mar 21 '18 19:03 therecipe

Hello. It's 2021 and QT 5.15 has prebuilt binaries for android arm32_7 and arm64_8. (And possibly x86 too, but i can't check because i've deleted it and installed QT 5.13, because qtdeploy can't find the new style libraries that have architecture in their names).

wicajif114 avatar Nov 23 '21 11:11 wicajif114