-
Notifications
You must be signed in to change notification settings - Fork 18k
x/mobile/cmd/gomobile: No implementation found | Android #17359
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
Comments
+1 import "fmt"
func Greetings(name string) string {
return fmt.Sprintf("Hello, %s!", name)
} ublic class contacts extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contacts);
String greetings = Android_test.greetings("Android and Gopher");
((TextView)findViewById(R.id.testText)).setText(greetings);
//((TextView)findViewById(R.id.testText)).setText("foo"); // works
}
} $ adb shell am start -n "im.ricochet.ricochet/im.ricochet.ricochet.contacts" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
|
It certainly looks like bind/genjava.go:GenC always generates that symbol, so the fact it's not being found suggests some other reason it is not being loaded. What kind of android device are you running on? What architecture? (To double check the basics: if you run gomobile with the -work flag it will leave the intermediate files around. Take a look and see if bind generated code for the symbol Java_go_avcl_1client_1usage_Avcl_1client_1usage__1init. Or @dballard, in your case, Java_go_android_1test_Android_1test__1init.) |
just finding error of this bug So move your golang package name |
Thank you @sinlov! first, @crawshaw , I found
So it got that far... But renaming the project camel case style to androidTest worked! It imports properly. Do you want to track that here or start a new fresh ticket? I am unblocked and moving forward so thanks to everyone! |
More notes: package two_words FATAL EXCEPTION: main
Process: im.ricochet.ricochet, PID: 15439
java.lang.UnsatisfiedLinkError: No implementation found for void go.two_words.Two_words._init() (tried Java_go_two_1words_Two_1words__1init and Java_go_two_1words_Two_1words__1init__)
at go.two_words.Two_words._init(Native Method)
It looks like what ever is doing the generation of package names based on splitting multi word go packages isn't following quite the same standard as the Java side is expecting Java tried: C generated code had: |
So according to JNI documentation It says JNI expects '_' in resources like functions to be replaced with '_1' this is backed by the above problem I'm having, and in your own code g.Printf("Java_%s_%s__1init(JNIEnv *env, jclass _unused) {\n", g.jniPkgName(), g.className()) So It looks like you need a small update to your name handling/translating code that swaps '_' for '_1' |
@quentinmit I'm hoping I've provided enough data to move this from "Needs more investigation" to the next step. If you have more questions please reach out. I'm still trying to wrap my head around the not small code base of mobile/bind but I feel someone who's already up on it is going to be dramatically faster than me on this :) |
I just ran into what looks to me to be this same problem or very close. I was getting the same error message (that's how I found this thread). However, rather than having an '' in the package name I had an '' in the function name. After reading @sinlov's comment I removed the '_' rebuilt the lib with gomobile and then the program in android studio. This did the trick. So it appears that this issue has not been fixed or at least missed my variant of the problem. |
Hello everyone, I know this thread is here for a while by now, but I run into this issue yesterday and I think it worth mentioning since it can be a future issue for others. What happened, I'm running gomobile exported libraries on a Flutter application and after my first successful integration, I wanted more. So I did a second library using the same method and then my problems started to happen. So, I found a way to "fix" it:
With that code, it compiled and I thought I had fixed it. But, later on, all my plugins stopped working. This was caused because of that same error on this thread No implementation found ... _init... whatever. But was obfuscated by this nothing is working at all. After a few tries later, I found this other thread: #15956. So, it is not possible to have 2 independent bindings in the same app. Hope it helps anyone that came up here with similar issues (it took me almost 4 hours on the weekend from the problem to the real fix). |
Hi,
My environment :
I made a .aar file with
gomobile bind -target android
, and imported it in my project.When I run the app in a simulator or device I get the following error :
I tried to update go and gomobile but I am stuck.
Thanks for your help.
The text was updated successfully, but these errors were encountered: