-
Notifications
You must be signed in to change notification settings - Fork 213
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
Fix examples/android code to actually run successfully #443
Conversation
import android.os.Bundle | ||
import android.widget.Button | ||
import android.widget.LinearLayout | ||
import android.widget.LinearLayout.LayoutParams | ||
import androidx.appcompat.app.AlertDialog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We leaned on appcompat to ensure it was included as part of the build.
Can you add something that requires it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This androidx.appcompat
dialog never actually worked properly, it crashed on runtime with:
You need to use a Theme.AppCompat theme (or descendant) with this activity.
I fixed it though so that we are able to use androidx.appcompat
properly
@@ -8,6 +8,9 @@ android_binary( | |||
incremental_dexing = 0, | |||
manifest = "src/main/AndroidManifest.xml", | |||
multidex = "native", | |||
manifest_values = { | |||
"lib_name": "lib", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these depend on the binary name rather than a dependency? This feels closer to how it would actually be used - the libraries have their own manifests. Right now you also still have two binaries with the same package name (app
and app3
) as they both define this as lib
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well no, this variable is used to inherit the right entry main activity which is currently inherited from the library package name since this binary target doesn't actually have any sources. For both app
and app3
the same lib
is used so it inherits the same MainActivity which is fine.
I guess the more proper fix which will resemble reality better is to have a unique AndroidManifest.xml per android_binary
target which I'm happy to do if you think it's worth it?
c19698b
to
2ec60f9
Compare
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
- Add a manifest with a main activity to launch - Use ``${lib_name}`` manifest variable in order to reuse the same manifest from multiple libs and inherit the right `MainActivity` from the right lib - Define `resource_files` attr to actually include the resource dir. Modify the code to actually use the resources. - Fixed the code to extend from `AppCompatActivity` in order to actually use `androidx.appcompat` and not crash on launch - Renamed `lib` target to `my_kt` and `lib2` to `my_android` in order to make it easier to distinguish between the generated output files during debugging. - Added `my_java` target to help with debugging when comparing plugin generation for java vs native android vs kotlin - Added `.bazelproject` file for IDE
2ec60f9
to
0d579e7
Compare
@googlebot I consent. |
Changes:
${lib_name}
manifest variable in order to reuse the same manifest from multiple libs and inherit the rightMainActivity
from the right libresource_files
attr to actually include the resource dir. Modify the code to actually use the resources.AppCompatActivity
in order to actually useandroidx.appcompat
and not crash on launchlib
target tomy_kt
andlib2
tomy_android
in order to make it easier to distinguish between the generated output files during debugging.my_java
target to help with debugging when comparing target output file generation for java vs native android vs kotlin.bazelproject
file for IDE