2016-09-07 2 views
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?

Antwort

0

Sie sollten das Android-SDK-Absichtspaket importieren, das im Import-Abschnitt nicht gefunden wird.

android.content.Intent

Das Problem ist SDK Intent-Klasse nicht gefunden.

+0

Funktioniert nicht. Ich habe 'import android.content.Intent;' hinzugefügt und immer noch dieselben Fehler. – slowydown

+0

einfach säubern und neu erstellen, wenn es funktioniert. Verwenden Sie Android Studio Setup oder andere Setup, z. B. Atom-und Befehlszeilen-Tools? –

+0

Ich habe PHPStrom benutzt, aber ich bewege mein Projekt einfach zu Android Studio. Wie Native React-Projekt in Android Studio neu erstellen? – slowydown

Verwandte Themen