0
Ich möchte meiner React Native App ein einfaches Modul hinzufügen. Aber ich habe eine Fehler:Modul zu React Native hinzufügen - Fehler: Symbol nicht gefunden
:app:compileDebugJavaWithJavacE:\project\android\app\src\main\java\com\androiddepends\HelloWorld.java:23: error: cannot find symbol
Intent intent = new Intent(Intent.ACTION_WIFI_SETTINGS);
^
symbol: class Intent
location: class HelloWorld
E:\project\android\app\src\main\java\com\androiddepends\HelloWorld.java:23: error: cannot find symbol
Intent intent = new Intent(Intent.ACTION_WIFI_SETTINGS);
^
symbol: class Intent
location: class HelloWorld
E:\project\android\app\src\main\java\com\androiddepends\HelloWorld.java:23: error: cannot find symbol
Intent intent = new Intent(Intent.ACTION_WIFI_SETTINGS);
^
symbol: variable Intent
location: class HelloWorld
E:\project\android\app\src\main\java\com\androiddepends\HelloWorld.java:24: error: cannot find symbol
if (intent.resolveActivity(getPackageManager()) != null) {
^
symbol: method getPackageManager()
location: class HelloWorld
4 errors
FAILED
Hier ist der Code:
package com.androiddepends;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import android.util.Log;
public class HelloWorld extends ReactContextBaseJavaModule {
public HelloWorld(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return "HelloWorld";
}
@ReactMethod
public void openWifiSettings() {
Intent intent = new Intent(Intent.ACTION_WIFI_SETTINGS);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
}
Irgendwelche Ideen?
Funktioniert nicht. Ich habe 'import android.content.Intent;' hinzugefügt und immer noch dieselben Fehler. – slowydown
einfach säubern und neu erstellen, wenn es funktioniert. Verwenden Sie Android Studio Setup oder andere Setup, z. B. Atom-und Befehlszeilen-Tools? –
Ich habe PHPStrom benutzt, aber ich bewege mein Projekt einfach zu Android Studio. Wie Native React-Projekt in Android Studio neu erstellen? – slowydown