-
Notifications
You must be signed in to change notification settings - Fork 113
What to replace arm-linux-androideabi
with in manifest?
#234
Comments
Here is the adb logcat dump of compiling a "default" project with this (The only different thing about the default manifest is that I've changed the name and don't ask for the camera) |
The appropriate ABI is "aarch64-linux-android". What do you mean when you say it doesn't work? Does it fail to build or fail to run? Is there an error? The There may be a way to call the appropriate functions using JNI and include them in the rust portion in android_native_app_glue.c but I don't have experience in that area. |
What NDK and SDK are you using? I don't have a pixel 2 but I haven't had any problems running the examples on the emulator, ARM7, or ARM64 devices. Any warnings or errors when building? |
It fails to run, with the logcat errors produced. It will try to "flash open" expanding from the app icon, and then it will simply go back to the home screen (Or the app drawer).
I tried that some time ago, when originally making the app, but I found that it is illegal to call said functions in the native activity thread, therefore forcing me to run them in the NativeActivity code, which runs in the main thread.
I installed the Android-29 packages, but then realized that the Pixel 2 runs on api level 28, so there was no point.
Those are mostly code-etiquette things, so they shouldn't really do much (Unless you're doing something wrong with uninitialized memory which would explain this). I use |
I tried with both |
Would you mind posting a non-functional APK? I have been unable to reproduce so far. Either that or checking the binary to see if the |
Do you happen to be building a release build? We are stripping symbols and that seems to be causing the problem. We won't need to strip all symbols. |
doze_widget.zip
And the following manifest: [package]
name = "doze_widget"
version = "0.1.0"
authors = ["OptimisticPeach <optimistic.peach@outlook.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[package.metadata.android]
# The target Android API level.
# "android_version" is the compile SDK version. It defaults to 29.
# (target_sdk_version defaults to the value of "android_version")
# (min_sdk_version defaults to 18) It defaults to 18 because this is the minimum supported by rustc.
android_version = 29
target_sdk_version = 29
min_sdk_version = 26
# Specifies the array of targets to build for.
# Defaults to "armv7-linux-androideabi", "aarch64-linux-android", "i686-linux-android".
build_targets = [ "aarch64-linux-android" ]
#
# The following value can be customized on a per bin/example basis. See multiple_targets example
# If a value is not specified for a secondary target, it will inherit the value defined in the `package.metadata.android`
# section unless otherwise noted.
#
# The Java package name for your application.
# Hyphens are converted to underscores.
# Defaults to rust.<target_name> for binaries.
# Defaults to rust.<package_name>.example.<target_name> for examples.
# For example: for a binary "my_app", the default package name will be "rust.my_app"
# Secondary targets will not inherit the value defined in the root android configuration.
# package_name = "rust.cargo.apk.advanced"
# The user-friendly name for your app, as displayed in the applications menu.
# Defaults to the target name
# Secondary targets will not inherit the value defined in the root android configuration.
label = "DozeWidget"
# Internal version number used to determine whether one version is more recent than another. Must be an integer.
# Defaults to 1
# See https://developer.android.com/guide/topics/manifest/manifest-element
version_code = 1
# The version number shown to users.
# Defaults to the cargo package version number
# See https://developer.android.com/guide/topics/manifest/manifest-element
version_name = "1.0"
# Path to your application's resources folder.
# If not specified, resources will not be included in the APK
res = "./res"
# Virtual path your application's icon for any mipmap level.
# If not specified, an icon will not be included in the APK.
icon = "@mipmap/ic_launcher"
# Path to the folder containing your application's assets.
# If not specified, assets will not be included in the APK
assets = "./assets"
# If set to true, makes the app run in full-screen, by adding the following line
# as an XML attribute to the manifest's <application> tag :
# android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen
# Defaults to false.
fullscreen = false
# The maximum supported OpenGL ES version , as claimed by the manifest.
# Defaults to 2.0.
# See https://developer.android.com/guide/topics/graphics/opengl.html#manifest
opengles_version_major = 3
opengles_version_minor = 2
# Adds extra arbitrary XML attributes to the <application> tag in the manifest.
# See https://developer.android.com/guide/topics/manifest/application-element.html
[package.metadata.android.application_attributes]
"android:debuggable" = "true"
"android:hardwareAccelerated" = "true"
# Adds extra arbitrary XML attributes to the <activity> tag in the manifest.
# See https://developer.android.com/guide/topics/manifest/activity-element.html
[package.metadata.android.activity_attributes]
"android:screenOrientation" = "unspecified"
"android:uiOptions" = "none"
# Adds a uses-feature element to the manifest
# Supported keys: name, required, version
# The glEsVersion attribute is not supported using this section.
# It can be specified using the opengles_version_major and opengles_version_minor values
# See https://developer.android.com/guide/topics/manifest/uses-feature-element
# [[package.metadata.android.feature]]
#name = "android.software.app_widgets"
#name = ""
[[package.metadata.android.feature]]
name = "android.hardware.vulkan.level"
version = "1"
required = false
# Adds a uses-permission element to the manifest.
# Note that android_version 23 and higher, Android requires the application to request permissions at runtime.
# There is currently no way to do this using a pure NDK based application.
# See https://developer.android.com/guide/topics/manifest/uses-permission-element
[[package.metadata.android.permission]]
name = "android.permission.WRITE_EXTERNAL_STORAGE"
max_sdk_version = 18
[[package.metadata.android.permission]]
name = "android.permission.CAMERA" End of manifestI'm not using release mode currently, and using it produces the same result. |
doze_widget.zip |
Are you using rust 1.37.0. I wasn't able to reproduce your issue. I just upgraded and now I have the same results. @mb64 what version of rust are you using when you started encountered your symbol issue? |
I just updated today (And yesterday) for trying to get this to work. If I use
(Which was updated just moments ago, and has the appropriate targets, etc, etc) |
Huzzah! You were right, using
I get a working APK, so it seems that something in rust 1.37.0 broke the build process 😬 |
Sorry, I wasn't clear. I was on 1.36 and it was working. 1.37 broke things for me. I looked at the symbol table and on 1.36.0 ANativeActivity_onCreate is in both |
I don't know what |
At the moment I don't know how to fix or work around the issue. The symbol isn't being exported from the shared object. For now everyone will need to use 1.36 until a solution is found. |
I don't know how to fix it properly but I thought of a temporary work around if you are willing to make some small mods to your version of cargo-apk. Add to the bottom of
Near the bottom of
@mb64 do you have any thoughts on how to best fix this issue? I'm going to hold off on any potential pull requests until we decide how to best fix it. Ideally we would just specify a linker command or something to rexport the symbol but the above work around appears to work. very limited testing so far. |
@OptimisticPeach thanks for your help in tracking down the issue and bringing it to our attention. @mb64 had ran into it but I didn't realize it affected the master branch due to it being a compatibility issue with 1.37.0. I went ahead and pushed a branch with this and some additional fixes #237 . This solution may not be the final solution but you can just use that branch for now. I'm not the maintainer but personally, I'd recommend starting a new issue for hiding the navigation bar so it isn't lost in the shuffle. |
One last note. I did some playing with hiding the navigation bar. It's possible without Java code. You'll need to modify It should be possible to do this from rust, using the jni crate and the current android glue, but I'm not going to invest the time in doing that right now. @mb64 has been working on refactoring some of this to move it out of cargo-apk. Once that is done it'll be easier to add an API to do this from rust. We'll have to consider the threading issues that you mentioned. The code below requires uses the JNIEnv of the native activity thread as opposed to getting a new one. This is okay in this case since it the JNIEnv provided by ANativeActivity is the correct one for the native activity callbacks. Since you were modifying cargo-apk anyways, you should be in the same state as you were before. Please note that there may be compatibility issues if using the Replace
The code is modified from https://stackoverflow.com/a/50831255 |
That sounds perfect! I will definitely use this, and thanks for all the help on doing this! I'm going to close this issue and instead make another issue dedicated to android startup things and an android api (Which would be capable of this) that run on the main thread. |
I'm also deferring the |
I'm trying to get a project to compile that previously (About 6 months ago) compiled, I get the following error when I try to compile it as is:
So, I try
armv7-linux-androideabi
, which successfully compiles and installs through adb, but fails to launch. I'm trying to run this on a Pixel 2, where I used to usearm-linux-androideabi
, cpu-z reports the kernel arch isaarch64
(Which apparently doesn't work) and the closest I could find wasarmv7-linux-androideabi
(Which doesn't work either).In PR #223 I read the following:
How might I go about making my app compile and run on my Pixel 2?
On a side note, I used to clone
cargo-apk
locally and edit theNativeActivity
code to remove the decoration and navigation bars (It's kind of difficult to play snake with them), where might I inject that code now? "Injected"/"replaced" code is here.The text was updated successfully, but these errors were encountered: