Skip to content
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

[Android] could you update readme for android installation react-native 0.18.0-rc #74

Closed
atteia opened this issue Jan 7, 2016 · 14 comments

Comments

@atteia
Copy link

atteia commented Jan 7, 2016

my MainActivity.java file is

package com.testapp;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;

import java.util.Arrays;
import java.util.List;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "testapp";
    }

    /**
     * Returns whether dev mode should be enabled.
     * This enables e.g. the dev menu.
     */
    @Override
    protected boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
    }

   /**
   * A list of packages used by the app. If the app uses additional views
   * or modules besides the default ones, add more packages here.
   */
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new MainReactPackage());
    }
}
@yfuks
Copy link
Contributor

yfuks commented Jan 7, 2016

Will look into it.

@marcshilling marcshilling changed the title could you update readme for android installation react-native 0.18.0-rc [Android] could you update readme for android installation react-native 0.18.0-rc Jan 7, 2016
@alexbndk
Copy link

This seems to work fine on react-native 0.18.0-rc.

package com.testapp;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;

import com.imagepicker.ImagePickerPackage;
import android.content.Intent;

import java.util.Arrays;
import java.util.List;

public class MainActivity extends ReactActivity {
    private ImagePickerPackage mImagePicker;

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "testapp";
    }

    /**
     * Returns whether dev mode should be enabled.
     * This enables e.g. the dev menu.
     */
    @Override
    protected boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
    }

   /**
   * A list of packages used by the app. If the app uses additional views
   * or modules besides the default ones, add more packages here.
   */
    @Override
    protected List<ReactPackage> getPackages() {
      mImagePicker = new ImagePickerPackage(this);

      return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        mImagePicker);
    }

    // handle onActivityResult
    @Override
    public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mImagePicker.handleActivityResult(requestCode, resultCode, data);
    }

}

@atteia
Copy link
Author

atteia commented Jan 12, 2016

thanks @alexbndk

@yfuks
Copy link
Contributor

yfuks commented Jan 12, 2016

Thank you @alexbndk. Will try this way and find out if there is any issues/
good practice with the react-native app lifetime

@yfuks
Copy link
Contributor

yfuks commented Jan 28, 2016

Since RN 0.18.0 is now released will make some update and add a "more easy way" to add the package in MainActivty with 2 lines

@jonolock91
Copy link

@alexbndk I've just upgraded to 0.19.0, and I've tried your exact code and I'm getting the following error when I try to compile, any ideas?

package com.MyAppName;

import com.facebook.react.ReactActivity;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;

import com.imagepicker.ImagePickerPackage;
import android.content.Intent;

import java.util.Arrays;
import java.util.List;

public class MainActivity extends ReactActivity {

    private ImagePickerPackage mImagePicker;

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "MyAppName";
    }

    /**
     * Returns whether dev mode should be enabled.
     * This enables e.g. the dev menu.
     */
    @Override
    protected boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
    }

    /**
    * A list of packages used by the app. If the app uses additional views
    * or modules besides the default ones, add more packages here.
    */
    @Override
    protected List<ReactPackage> getPackages() {
      mImagePicker = new ImagePickerPackage(this);

      return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new VectorIconsPackage(),
        mImagePicker);
    }  

    // handle onActivityResult
    @Override
    public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mImagePicker.handleActivityResult(requestCode, resultCode, data);
    }
}

@yfuks
Copy link
Contributor

yfuks commented Feb 2, 2016

You paste your implementation not an issue

@jonolock91
Copy link

The error message I get back is the following:

/Users/jono/MyApp/android/app/src/main/java/com/MyApp/MainActivity.java:3: error: cannot find symbol
import com.facebook.react.ReactActivity;
                         ^
  symbol:   class ReactActivity
  location: package com.facebook.react
/Users/jono/MyApp/android/app/src/main/java/com/MyApp/MainActivity.java:14: error: cannot find symbol
public class MainActivity extends ReactActivity {
                                  ^
  symbol: class ReactActivity
/Users/jono/MyApp/android/app/src/main/java/com/MyApp/MainActivity.java:22: error: method does not override or implement a method from a super type
    @Override
    ^
/Users/jono/MyApp/android/app/src/main/java/com/MyApp/MainActivity.java:31: error: method does not override or implement a method from a super type
    @Override
    ^
/Users/jono/MyApp/android/app/src/main/java/com/MyApp/MainActivity.java:40: error: method does not override or implement a method from a super type
    @Override
    ^
/Users/jono/MyApp/android/app/src/main/java/com/MyApp/MainActivity.java:42: error: incompatible types: MainActivity cannot be converted to Activity
      mImagePicker = new ImagePickerPackage(this);
                                            ^
/Users/jono/MyApp/android/app/src/main/java/com/MyApp/MainActivity.java:47: error: incompatible types: MainActivity cannot be converted to Activity
        new ImagePickerPackage(this));
                               ^
/Users/jono/MyApp/android/app/src/main/java/com/MyApp/MainActivity.java:51: error: method does not override or implement a method from a super type
    @Override
    ^
/Users/jono/MyApp/android/app/src/main/java/com/MyApp/MainActivity.java:53: error: cannot find symbol
        super.onActivityResult(requestCode, resultCode, data);
        ^
  symbol:   variable super
  location: class MainActivity
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
9 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

@yfuks
Copy link
Contributor

yfuks commented Feb 2, 2016

Since you get the folowing error

/Users/jono/MyApp/android/app/src/main/java/com/MyApp/MainActivity.java:3: error: cannot find symbol
import com.facebook.react.ReactActivity;

I assume that you don't update you RN version in your package.json or you miss something in your update of RN.

Since it's not related to this package please open an issue on the React-native repo or look closely on the react-native documentation if you get this kind of issue.

@jonolock91
Copy link

ok thanks for your help

@kacperpotega
Copy link

@alexbndk's code worked for me when installing the component on 0.20.0. Would have saved me quite some time if this was added to the README.

@marcshilling
Copy link
Contributor

README updated for latest android installation instructions

@codepandy
Copy link

@alexbndk I changed my code like your,but had a error:"package com.imagepicker does not exist." I searched the package use google,but I couldn't find out it.how to solve the problem? I used react-native to develope android.

@heliokroger
Copy link

@codepandy Add compile project(':react-native-image-picker') on your android/build.gradle dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants