react-native-gcm-android icon indicating copy to clipboard operation
react-native-gcm-android copied to clipboard

App crashes when App is killed completely..

Open jojonarte opened this issue 9 years ago • 45 comments

I've been working on this app for a while using your module, it seems fine for when the app is in the background but crashes when app is completely killed from the device. Is there any workaround for this issue?? Please let me know :(

jojonarte avatar Jan 18 '16 04:01 jojonarte

What version of React Native and react-native-gcm-android are you using?

oney avatar Jan 18 '16 06:01 oney

"react-native-gcm-android": "0.1.6", "react-native": "^0.17.0", are the versions that I'm using.

On 18 January 2016 at 14:10, Howard Yang [email protected] wrote:

What version of React Native and react-native-gcm-android are you using?

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/26#issuecomment-172434906 .

JOJO

jojonarte avatar Jan 18 '16 06:01 jojonarte

Can you run adb logcat to get some logs?

oney avatar Jan 18 '16 07:01 oney

Hi oney, this is my log.

D/WifiService(  585): releaseWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@20e05681}
I/GCM     (  842): GCM message com.carpetpro_mobile 0:1453102696504996%fa6b524cf9fd7ecd
D/RNGcmListenerService(14475): sendNotification
D/com.oney.gcm.GcmModule(14475): sadfjasidfjliasf444
D/BackgroundService(14475): onStartCommand
D/BackgroundService(14475): DeclaredField: APPLICATION_ID
D/BackgroundService(14475): DeclaredField: BUILD_TYPE
D/BackgroundService(14475): DeclaredField: FLAVOR
D/BackgroundService(14475): DeclaredField: VERSION_NAME
D/BackgroundService(14475): DeclaredField: DEBUG
D/BackgroundService(14475): DeclaredField value: true
W/unknown:React(14475): The packager does not seem to be running as we got an IOException requesting its status: failed to connect to /10.0.3.2 (port 8081) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)
I/art     (14475): Thread[1,tid=14475,WaitingForJniOnLoad,Thread*=0xf4306800,peer=0x73b83970,"main"] recursive attempt to load library "/data/app/com.carpetpro_mobile-2/lib/x86/libreactnativejni.so"

jojonarte avatar Jan 18 '16 07:01 jojonarte

Oh, I guess it is related to this. Run below command to generate index.android.bundle, and then run react-native run-android

react-native bundle --platform android --dev false --entry-file index.android.js \
  --bundle-output android/app/src/main/assets/index.android.bundle \
  --assets-dest android/app/src/main/res/

oney avatar Jan 18 '16 08:01 oney

It still results in the same issue :(

jojonarte avatar Jan 18 '16 09:01 jojonarte

Do you load js bundle from 10.0.3.2:8081?

oney avatar Jan 18 '16 10:01 oney

I do.

On 18 January 2016 at 18:05, Howard Yang [email protected] wrote:

Do you load js bundle from 10.0.3.2:8081?

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/26#issuecomment-172485209 .

JOJO

jojonarte avatar Jan 18 '16 10:01 jojonarte

:(

On 18 January 2016 at 18:13, Joselito Narte [email protected] wrote:

I do.

On 18 January 2016 at 18:05, Howard Yang [email protected] wrote:

Do you load js bundle from 10.0.3.2:8081?

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/26#issuecomment-172485209 .

JOJO

JOJO

jojonarte avatar Jan 18 '16 10:01 jojonarte

Maybe it's related to https://github.com/facebook/react-native/issues/3167#issuecomment-145736532 Please try run adb reverse tcp:8081 tcp:8081 then react-native run-android

oney avatar Jan 18 '16 10:01 oney

I just did this and it still didn't work out :'(

On 18 January 2016 at 18:27, Howard Yang [email protected] wrote:

Maybe it's related to facebook/react-native#3167 (comment) https://github.com/facebook/react-native/issues/3167#issuecomment-145736532 Please try run adb reverse tcp:8081 tcp:8081 then react-native run-android

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/26#issuecomment-172491292 .

JOJO

jojonarte avatar Jan 18 '16 10:01 jojonarte

Can you show index.android.js to me? You can remove irrelevant codes.

oney avatar Jan 18 '16 11:01 oney

/**

  • Sample React Native App
  • https://github.com/facebook/react-native */ 'use strict';

var React = require('react-native'); var db = require('./models/User'); var JobOrderDB = require('./models/JobOrder'); var JobOrderStatDB = require('./models/JobOrderStatusLookup'); var Login = require('./components/LoginView.js'); var config = require('./config/app'); var appUpdate = require('./modules/AppUpdate'); var appUtil = require('./modules/AppUtilitiesModule'); var DeviceInfo = require('react-native-device-info'); var androidGeolocationModule = require('./modules/AndroidGeolocationModule'); var images = require('./config/constants/images'); var AppData = require('./models/App'); var GcmAndroid = require('react-native-gcm-android'); import Notification from 'react-native-system-notification'; var networkUtil = require('./modules/NetworkUtilitiesModule');

var { AppRegistry, StyleSheet, Text, ListView, Image, TextInput, NativeModules, View, DrawerLayoutAndroid, Navigator, BackAndroid, ToastAndroid, TouchableNativeFeedback, TouchableHighlight, TouchableOpacity, Dimensions } = React;

var cssVar = require('cssVar'); var onMenuClick = ''; var navig = ''; var _gcmAction =(action)=>{ console.log("gcm action>>>>",action); switch(action){ case 'file_upload': console.log("gcm action",action); ToastAndroid.show('',ToastAndroid.SHORT); break; case 'job_change': console.log("gcm action",action); ToastAndroid.show('',ToastAndroid.SHORT); break; case 'device_logout': appUtil.clearApplicationData();

                                    console.log("gcm action","other

device used your credentials"); break; default: console.log("gcm action",action); } }; if (GcmAndroid.launchNotification) { console.log('GcmAndroid.launchNotification:', GcmAndroid.launchNotification); var notification = GcmAndroid.launchNotification; var info = JSON.parse(notification.info); _gcmAction(info.action);

GcmAndroid.createNotification({
    subject: info.subject,
    message: info.message,
    largeIcon: 'ic_launcher',
    autoCancel: true,
    ticker: 'new notification!',
});
GcmAndroid.stopService();

} else { var app_mobile = React.createClass({

    getInitialState: function () {
        return {
            loading: false,
            email: '',
            token: '',
            position: {
            coords: {
                lat: '',
                lng: ''
            }
            },
            location:'',
            error: '',
            gcmLogged:false,
        };
    },
    requestNewLocation: function() {
        androidGeolocationModule.getCurrentLocation(
        (position) => this.setState({position: position}),
        (error) => this.setState({error: error})
        );
    },
    componendDidUpdate: function(prevProps,prevState) {
        requestNewLocation();
    },
    addBackButton: function (navigator) {
        var self = this;
        BackAndroid.addEventListener('hardwareBackPress', function () {
            navigator.pop();
            return true;
        });
    },
    componentWillMount: function() {
        this.setState({gcmLogged : false})

    },
    componentDidMount: function () {
        var self = this;

        androidGeolocationModule.getCurrentLocation(
        (position) => this.setState({position: position}),
        (error) => this.setState({error: error})
        );

        if(self.gcmLogged != true){

            db.FetchSession(function (err, data) {
            if (data.length > 0) {
                self.setState({
                    loading: true,
                    email: data[0].username
                });
            }
            else {
                self.setState({
                    loading: true,
                    email: ''
                });
            }
        });

        }

        GcmAndroid.addEventListener('register', function(token) {
            AppData.DeleteData();
            AppData.InsertData(token);
            console.log('send gcm token to server', token);
            self.setState({
                token: token
            })
        });

        GcmAndroid.addEventListener('notification',

function(notification) { console.log('receive gcm notification', notification); console.log('GcmAndroid.isInForeground', GcmAndroid.isInForeground);

            var info = JSON.parse(notification.data.info);

            console.log('RECEIVED NOTIFICATION');

            if (!GcmAndroid.isInForeground) {
                GcmAndroid.createNotification({
                    subject: info.subject,
                    message: info.message,
                    largeIcon: 'ic_launcher',
                    autoCancel: true,
                    ticker: 'new notification!',
                });
                _gcmAction(info.action);
                this.setState({gcmLogged:true});
            }

        });
        GcmAndroid.requestPermissions();
    },
    renderLoading: function () {
        return (
            <View style={styles.loading_container}>
                <Text>
                    Loading...
                </Text>
            </View>
        );
    },
    drawerInstance : {
        instance : {openDrawer : function(){}}
    },

    initInstance : function(instance){
        console.log(instance);
        this.drawerInstance.instance = instance;
    },

    _onMenuClick : function(event){
        this.drawerInstance.instance.openDrawer();
    },

    _onDrawerItemClick : function(event){
        this.drawerInstance.instance.closeDrawer();
    },

    checkUpdate: function() {
        this._onDrawerItemClick();
        appUpdate.updateApp("GO");
    },

    render: function () {

        onMenuClick = this._onMenuClick;

console.log('POSSSSIITIOOON'+JSON.stringify(this.state.position)); // ToastAndroid.show(this.state.,ToastAndroid.SHORT); var navigationView = ( <View style={{flex: 1, backgroundColor: '#253039'}}> <TouchableHighlight onPress={this._change.bind(this,'SystemInfos')}> <View style={styles.drawerMenu}> <Image source={images.SYS_INFO_ICON} style={styles.drawerIcon}></Image><Text style={{margin: 15, marginLeft: 2, fontSize: 15, textAlign: 'left', paddingLeft: 10, paddingRight:10,color: '#FFF'}}>System Info</Text> </View> </TouchableHighlight> <TouchableHighlight onPress={this.checkUpdate}> <View style={styles.drawerMenu}> <Image source={images.UPDATE_APP_ICON} style={styles.drawerIcon}></Image><Text style={{margin: 15, marginLeft: 2, fontSize: 15, textAlign: 'left', paddingLeft: 10, paddingRight:10,color: '#FFF'}}>Update App</Text> </View> </TouchableHighlight> </View> );

        if (!this.state.loading) {
            return this.renderLoading();
        }
        else {
            var initialRoute = {};
            if (this.state.email === ''|| this.gcmLogged == false)
                initialRoute = {id: 'Login', index: 0};
            else
                initialRoute = {id: 'WorkerJob', index: 0, title:

"Installer App"}; return ( <DrawerLayoutAndroid drawerWidth={175} drawerHeight={100} ref={this.initInstance} drawerPosition={DrawerLayoutAndroid.positions.Left} renderNavigationView={() => navigationView} >

                    <Navigator
                        ref="carpet_pro_nav"
                        style={styles.container}
                        initialRoute={initialRoute}
                        title="Carpet Pros"
                        renderScene={this.renderScene.bind(this)}
                        configueScene = {(route) =>

Navigator.SceneConfigs.FloatFromRight}

                        navigationBar={
                                  <Navigator.NavigationBar
                                    routeMapper={navMap}
                                    style={styles.navBar}
                                    actions={[{title: 'Settings',
                                    icon:

require('./config/constants/images').HAMBURGER, show: 'always'}]}/> } /> </DrawerLayoutAndroid> ); } },

    popAll: function(){
        this.refs.carpet_pro_nav.popToTop();
    },

    renderScene: function (route, navigator){
        console.log('renderScene [navigator: ' + navigator + ']');
        var self = this;
        self.addBackButton(navigator);
        var routeID = route.id;
        var nextIndex = route.index + 1;
         this.navig = navigator;

        if (routeID === 'Login') {

            return (
                <Login
                   ...
                    }}/>
            );
        }
        if (routeID === 'WorkerJob') {
            var WorkerJobListView =

require('./components/WorkerJobListView.js');

            return (
                <WorkerJobListView
                    ...}/>

            );
        }
        if (routeID === 'LienWaiver') {
            var Lienwaiver = require('./components/Lienwaiver');

            return (
                <Lienwaiver
                    .../>
            );
        }
        if (routeID === 'WebView') {
            var WebView = require('./components/WebViewAndroid.js');

            return (
                <WebView
                    .../>
            );
        }
        if (routeID === 'OrderDetailsList') {
            var WorkOrder =

require('./components/WorkOrderDetailsList.js');

            return (
                <WorkOrder
                   ...  />
            );
        }
        if (routeID === 'Signature') {
            var SignatureView =

require('./components/SignatureView.js');

            return (
                <SignatureView
                   ...  />
            );
        }
        if (routeID === 'SignedWaiver') {
            var SignedWaiver = require('./components/SignedWaiver');

            return (
                <SignedWaiver
                   .../>
            )
        }
        if(routeID == 'SystemInfos'){
            var SystemInfos = require('./components/SystemInfos');

            return(
                <SystemInfos
                   ... />
            )
        } else {
            this.requestNewLocation();
        }
    },
    _change(route){
        var self = this;
        var location;
        this._onDrawerItemClick();
                    self.navig.push({id: route,
                        navigator:self.navig,

location:self.state.position.coords.lat+','+self.state.position.coords.lng, email:self.state.email, title:'System Info', }) } });

var NavigationBarRouteMapper = { LeftButton: function (route, navigator, index, navState) { this.navig = navigator; if (route.id !== 'Login' && route.id !== 'WorkerJob') { return ( <TouchableOpacity onPress={() => {

                    navigator.pop()
             }}>
                <Image
                    style={styles.backButton}

source={require('./config/constants/images').BACK_NAV_BUTTON}/> </TouchableOpacity> ) }else { return ( <TouchableOpacity onPress={() => {

                    onMenuClick()

                }}>
                <Image
                    style={styles.backButton}

source={require('./config/constants/images').HAMBURGER}/> </TouchableOpacity> ) } }, RightButton: function (route, navigator, index, navState) {

},
Title: function (route, navigator, index, navState) {
    return (
        <Text style={styles.navBarTitleText}>
            {route.title}
        </Text>
    );
},

}; var navMap = NavigationBarRouteMapper; var styles = StyleSheet.create({ container: { flex: 1, textAlign: 'center' }, signature_layout: { width: 250, height: 250, backgroundColor: '#FFFFFF' }, drawerMenu: { flex: 1, flexDirection: 'row', }, navBar: { backgroundColor: '#253039', //height: 45 }, navBarTitleText: { fontSize: 15, color: '#ffffff', fontWeight: '400', //marginTop: 15, marginTop: 12, width: Dimensions.get('window').width - 150, textAlign: 'center' }, navBarLeftButton: { paddingLeft: 10, }, navBarRightButton: { paddingRight: 10 }, navBarButtonText: { color: cssVar('fbui-accent-blue') }, arrow: { marginLeft: 2, marginTop: 18, width: 20, height: 20, backgroundColor: 'transparent', resizeMode: 'contain'

},
loading_container: {
    flex: 1,
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
    borderWidth: 1
},
logout: {
    color: cssVar('fbui-accent-blue'),
    fontSize: 20,
    marginTop: 12,
    textAlign: 'center'
},
backButton: {
    width: 20,
    height: 20,
    margin: 18
},
drawerIcon: {
    width: 20,
    height: 20,
    margin: 18,
},

});

AppRegistry.registerComponent('app_mobile', () => app_mobile); }

On 18 January 2016 at 19:36, Howard Yang [email protected] wrote:

Can you show index.android.js to me? You can remove irrelevant codes.

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/26#issuecomment-172504348 .

JOJO

jojonarte avatar Jan 18 '16 11:01 jojonarte

Hmmm... It seems it's not related. Can you try generating signed release APK to test whether the issue happened? https://facebook.github.io/react-native/docs/signed-apk-android.html

oney avatar Jan 18 '16 12:01 oney

Yup I already did that yesterday. :'(

On 18 January 2016 at 20:02, Howard Yang [email protected] wrote:

Hmmm... It seems it's not related. Can you try generating signed release APK to test whether the issue happened? https://facebook.github.io/react-native/docs/signed-apk-android.html

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/26#issuecomment-172510526 .

JOJO

jojonarte avatar Jan 18 '16 12:01 jojonarte

Can you try again and get the logs?

oney avatar Jan 18 '16 12:01 oney

Any idea how to fix this? com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\jojonarte\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1

On 18 January 2016 at 20:19, Howard Yang [email protected] wrote:

Can you try again and get the logs?

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/26#issuecomment-172513485 .

JOJO

jojonarte avatar Jan 18 '16 14:01 jojonarte

Please try cleaning the project

cd android
./gradlew clean

oney avatar Jan 18 '16 14:01 oney

The error still persists :(

On 18 January 2016 at 22:21, Howard Yang [email protected] wrote:

Please try cleaning the project

cd android ./gradlew clean

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/26#issuecomment-172538829 .

JOJO

jojonarte avatar Jan 18 '16 14:01 jojonarte

Have you tested the demo project? https://github.com/oney/TestGcm

oney avatar Jan 19 '16 07:01 oney

The demo project doesn't crash as you are using a custom java wrapper which is a service, and you handle all your notifications there. I think the bridge on React native and android is killed when app is killed making the issue. Is there a workaround on your javascript module??

On 19 January 2016 at 15:30, Howard Yang [email protected] wrote:

Have you tested the demo project? https://github.com/oney/TestGcm

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/26#issuecomment-172763258 .

JOJO

jojonarte avatar Jan 19 '16 07:01 jojonarte

In demo project, when the app is killed, we still handle notification in JS code. Please see index.android.js of TestGcm We handle notification when the app is killed in

if (GcmAndroid.launchNotification) {
  console.log('GcmAndroid.launchNotification:', GcmAndroid.launchNotification);
  var notification = GcmAndroid.launchNotification;
  var info = JSON.parse(notification.info);
  Notification.create({
    subject: info.subject,
    message: info.message,
  });
  GcmAndroid.stopService();
}

When it receives GCM notification and the app is killed, it will launch a service that creates a new React Native instance in the background.

oney avatar Jan 19 '16 07:01 oney

Should I use System notification module as you did there?

On 19 January 2016 at 15:47, Howard Yang [email protected] wrote:

In demo project, when the app is killed, we still handle notification in JS code. Please see index.android.js of TestGcm https://github.com/oney/TestGcm/blob/master/index.android.js We handle notification when the app is killed in

if (GcmAndroid.launchNotification) { console.log('GcmAndroid.launchNotification:', GcmAndroid.launchNotification); var notification = GcmAndroid.launchNotification; var info = JSON.parse(notification.info); Notification.create({ subject: info.subject, message: info.message, }); GcmAndroid.stopService(); }

When it receives GCM notification and the app is killed, it will launch a service https://github.com/oney/react-native-gcm-android/blob/master/android/src/main/java/com/oney/gcm/BackgroundService.java that creates a new React Native instance in the background.

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/26#issuecomment-172766726 .

JOJO

jojonarte avatar Jan 19 '16 16:01 jojonarte

Yes, you should.

oney avatar Jan 19 '16 16:01 oney

I'm also getting a crash if the app is closed.

E/ReactNativeJS(26189): undefined is not an object (evaluating 'i.SHORT')
I/ReactNativeJS(26209): 'GcmAndroid.launchNotification:', { info: '{"subject":"Hello...","message":"Hello from the server side!"}',
I/ReactNativeJS(26209):   collapse_key: 'do_not_collapse' }

However I'm getting another weird behaviour: I have installed the TestGcm app and my app with different tokens and Authorizations keys. However if both apps are closed and I send a notification to my app (my token and my authorization key) the crash occurs but when I click the notification your app is the one that opens. Actually, I didn't have the console log of GcmAndroid.launchNotification so it's the TestGcm app that receives the if (GcmAndroid.launchNotification) {.

nbastoWM avatar Jan 22 '16 12:01 nbastoWM

Can you use adb logcat to get logs when crashing?

oney avatar Jan 22 '16 13:01 oney

I usally get logs with:

adb logcat *:S ReactNative:V ReactNativeJS:V

When I open the app:

I/ReactNativeJS( 8770): Running application "WMMyCityApp" with appParams: {"initialProps":{},"rootTag":1}. __DEV__ === false, development-level warning are OFF, performance optimizations are ON
I/ReactNativeJS( 8770): 'send gcm token to server', 'cH49NsZuMvM:APA91bEtw1JIOF-c_r7DjHuEO496HulXGCLnt3s3ysiXBuTuJDZgPV_A3wHNqxkQ2LkirbR-0WzxIyh__5GNI5tXr394nnMTcingSn7GnVqSv5QpuYnkkEVHjIi2DwwbCDs-BFZEle6k'

When I receive a notification with all apps closed:

E/ReactNativeJS( 8850): undefined is not an object (evaluating 'i.SHORT')
I/ReactNativeJS( 8870): 'GcmAndroid.launchNotification:', { info: '{"subject":"Hello GCM2","message":"Hello from the server side!"}',
I/ReactNativeJS( 8870):   collapse_key: 'do_not_collapse' }

NOTE: That console log is from TestGcm but the token sent was for my App.

Now I tried to generate a signed APK but I got this error.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/local/opt/android-sdk/build-tools/23.0.1/aapt'' finished with non-zero exit value 1

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processReleaseResources'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:310)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/local/opt/android-sdk/build-tools/23.0.1/aapt'' finished with non-zero exit value 1
    at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:147)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:98)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:243)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:230)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 49 more
Caused by: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/local/opt/android-sdk/build-tools/23.0.1/aapt'' finished with non-zero exit value 1
    at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:42)
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:919)
    at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:138)
    ... 57 more
Caused by: org.gradle.process.internal.ExecException: Process 'command '/usr/local/opt/android-sdk/build-tools/23.0.1/aapt'' finished with non-zero exit value 1
    at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:365)
    at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:40)
    ... 59 more


BUILD FAILED

The react-native run-android goes OK but generating the APK gives this error. Without this modules I can generate the signed APK just fine.

nbastoWM avatar Jan 22 '16 14:01 nbastoWM

Please use adb logcat to get the logs about Java, not just javascript.

oney avatar Jan 22 '16 14:01 oney

Sorry for the long comment:

I did adb reverse ... as I saw in the complete logs but it always crash if no app is opened.

I/InputDispatcher( 2765): Delivering touch to (3356): action: 0x1, toolType: 1
I/InputDispatcher( 2765): Delivering touch to (3275): action: 0x1, toolType: 1
D/com.facebook.a.a( 4432): Got unexpected exception: java.io.WriteAbortedException: Read an exception; java.io.NotSerializableException: org.json.JSONObject
W/Settings( 4500): Setting android_id has moved from android.provider.Settings.System to android.provider.Settings.Secure, returning read-only value.
D/SSRM:n  ( 2765): SIOP:: AP = 320, CUR = 450, LCD = 200
D/SensorService( 2765): [SO] -0.125 0.212 9.741
V/AlarmManager( 2765): waitForAlarm result :4
I/GCM     ( 4002): GCM message com.wmmycityapp 0:1453474092530395%41b09ea7f9fd7ecd
V/BroadcastQueue( 2765): [background] Process cur broadcast BroadcastRecord{1164de0d u0 com.google.android.c2dm.intent.RECEIVE} DELIVERED for app ProcessRecord{389d13e0 8850:com.wmmycityapp/u0a515}
D/ActivityManager( 2765): caller:android.app.ApplicationThreadProxy@2ea8b1c2, r.packageName :com.wmmycityapp
D/RNGcmListenerService( 8850): sendNotification
V/BroadcastQueue( 2765): [background] Process cur broadcast BroadcastRecord{32bfb310 u0 com.oney.gcm.GCMReceiveNotification} DELIVERED for app ProcessRecord{188f5355 8870:com.testgcm/u0a511}
D/ActivityManager( 2765): startService callerProcessName:com.testgcm, calleePkgName: com.testgcm
D/ActivityManager( 2765): caller:android.app.ApplicationThreadProxy@128e4e09, r.packageName :com.testgcm
D/BackgroundService( 8870): onStartCommand
I/Sensors ( 2765): HAL:flush - mFlushSensorEnabledVector=2 res=0
V/BroadcastQueue( 2765): [background] Process cur broadcast BroadcastRecord{32bfb310 u0 com.oney.gcm.GCMReceiveNotification} DELIVERED for app ProcessRecord{389d13e0 8850:com.wmmycityapp/u0a515}
I/Sensors ( 2765): HAL:readEvents - Stored flush complete event for sensor=2, fl_cnt=0
D/SensorManager( 8870): registerListener :: 2, MPL Accelerometer, 66667, 0,
D/ActivityManager( 2765): startService callerProcessName:com.wmmycityapp, calleePkgName: com.wmmycityapp
D/ActivityManager( 2765): caller:android.app.ApplicationThreadProxy@3edd822f, r.packageName :com.wmmycityapp
D/BackgroundService( 8850): onStartCommand
I/Sensors ( 2765): HAL:flush - mFlushSensorEnabledVector=2 res=0
D/SensorManager( 8850): registerListener :: 2, MPL Accelerometer, 66667, 0,
W/unknown:React( 8850): You seem to be running on device. Run 'adb reverse tcp:8081 tcp:8081' to forward the debug server's port to the device.
W/unknown:React( 8850): You seem to be running on device. Run 'adb reverse tcp:8081 tcp:8081' to forward the debug server's port to the device.
I/Sensors ( 2765): HAL:readEvents - Sent flush complete events 1 times
I/Sensors ( 2765): HAL:readEvents - Stored flush complete event for sensor=2, fl_cnt=0
I/Sensors ( 2765): HAL:readEvents - Sent flush complete events 1 times
D/StatusBar.NetworkController( 3003): refreshViews connected={ wifi } level=2 combinedSignalIconId=0x7f0206ac/com.android.systemui:drawable/stat_sys_wifi_signal_4 mobileLabel=NOS wifiLabel="MATRIX" emergencyOnly=false combinedLabel="MATRIX" mAirplaneMode=false mDataActivity=0 mPhoneSignalIconId=0x7f0205d9/com.android.systemui:drawable/stat_sys_signal_2_auto_rotate mQSPhoneSignalIconId=0x7f0201ae/com.android.systemui:drawable/ic_qs_signal_2 mDataDirectionIconId=0x0/(null) mDataSignalIconId=0x7f0205d9/com.android.systemui:drawable/stat_sys_signal_2_auto_rotate mDataTypeIconId=0x7f020488/com.android.systemui:drawable/stat_sys_data_connected_h mQSDataTypeIconId=0x7f0201bb/com.android.systemui:drawable/ic_qs_signal_h mNoSimIconId=0x0/(null) mWifiIconId=0x7f0206ac/com.android.systemui:drawable/stat_sys_wifi_signal_4 mQSWifiIconId=0x7f020370/com.android.systemui:drawable/qs_tile_wifi_signal_4 mWifiActivityIconId=0x7f020660/com.android.systemui:drawable/stat_sys_signal_inout mBluetoothTetherIconId=0x7f020689/com.android.systemui:drawable/stat_sys_tether_bluetooth
D/StatusBar.NetworkController( 3003): refreshNwBoosterIndicator - setNWBoosterIndicators(false)
D/StatusBar.NetworkController( 3003): refreshNwBoosterIndicator - setNWBoosterIndicators(false)
D/StatusBar.NetworkController( 3003): refreshNwBoosterIndicator - setNWBoosterIndicators(false)
D/StatusBar.NetworkController( 3003): refreshNwBoosterIndicator - setNWBoosterIndicators(false)
I/ReactNativeJS( 8870): 'GcmAndroid.launchNotification:', { info: '{"subject":"Hello GCM2","message":"Hello from the server side!"}',
I/ReactNativeJS( 8870):   collapse_key: 'do_not_collapse' }
D/ApplicationPolicy( 2765): isStatusBarNotificationAllowedAsUser: packageName = com.testgcm,userId = 0
I/ReactSystemNotification( 8870): Notification Show: 5309
I/ReactSystemNotification( 8870): Notification Created: 5309
D/WindowManager( 2765): showStatusBarByNotification() mOpenByNotification=false
D/AudioService( 2765): getStreamVolume 5 index 30
D/MotionRecognitionService( 2765):  open api 0
E/MotionRecognitionService( 2765): enable_sensor
D/MotionRecognitionService( 2765):   .registerCallback : 1, motion_sensors=3, client=
D/MotionEngine( 2765): [MotionEngine]->Build Binary Type(user):0
D/MotionRecognitionService( 2765):   .isMotionEngineEnabled : true
D/MotionEngine( 2765): [@@@ Motion Engine @@@] InitializeMotionManager ALL, DPS setting 1
D/MotionRecognitionService( 2765):   .initializeMotionEngine
D/MREngine( 2765): [@@@@@SR Motion Engine @@@] CRM Initialize!!!!!
V/MotionRecognitionService( 2765):  .updateOrientation : 28
D/MotionEngine( 2765): [@@@SR Motion Engine @@@] init
D/MotionRecognitionService( 2765): Acquire sensors : Settings = 1100101000000000000101
D/SensorService( 2765): [SO] changed settle time [1]
D/MotionRecognitionService( 2765): Acquired sensors for motion : 11
D/SensorService( 2765): [SO] setDelay [66000000]
D/SensorService( 2765): [SO] activate (ident=0x85608100, enabled=1)
D/SensorManager( 2765): registerListener :: 1600221811, Screen Orientation Sensor, 66667, 0,
E/MotionRecognitionService( 2765): setMotionCMD 300
I/Sensors ( 2765): HAL:batch called - handle=2, flags=0, period=5000000, timeout=0
I/Sensors ( 2765): HAL:resetDataRates mEnabled=4
I/Sensors ( 2765): CompassSensor::setDelay, delay=10000000
V/MediaPlayer-JNI( 3003): native_setup
V/MediaPlayer( 3003): constructor
D/AkmSensor( 2765): Magnetic_Set_Delay , delay = 20000000
V/MediaPlayer( 3003): setListener
V/MediaPlayer-JNI( 3003): setParameter: key 1400
V/MediaPlayer( 3003): MediaPlayer::setParameter(1400)
V/MediaPlayer-JNI( 3003): setAudioStreamType: 5
V/MediaPlayer( 3003): MediaPlayer::setAudioStreamType
D/RingtoneManager( 3003): getActualDefaultRingtoneUri  type    :2
I/Sensors ( 2765): MPLSensor::resetDataRates, gyro_delay=5000000, accel_delay=5000000, mag_delay=20000000 orient_delay=5000000 grv_delay=5000000
D/RingtoneManager( 3003): checkDefaultRingtoneProperUri : path and URI match to each other
D/RingtoneManager( 3003): setCacheUri uri:content://media/external/audio/media/19806, external path:/storage/extSdCard, path:/storage/emulated/0/zedge/notification_sound/BBM_Tone-notification_sound-1715642.mp3
I/Sensors ( 2765): HAL:flush - mFlushSensorEnabledVector=2 res=0
I/Sensors ( 2765): HAL:batch called - handle=2, flags=0, period=20000000, timeout=0
D/SensorService( 2765): [SO] Reset Rotation Old [100], Init [1]
I/Sensors ( 2765): HAL:readEvents - Stored flush complete event for sensor=2, fl_cnt=0
I/Sensors ( 2765): HAL:resetDataRates mEnabled=4
I/Sensors ( 2765): CompassSensor::setDelay, delay=20000000
D/AkmSensor( 2765): Magnetic_Set_Delay , delay = 20000000
I/Sensors ( 2765): MPLSensor::resetDataRates, gyro_delay=20000000, accel_delay=20000000, mag_delay=20000000 orient_delay=20000000 grv_delay=20000000
E/ReactNativeJS( 8850): undefined is not an object (evaluating 'RCTToastAndroid.SHORT')
V/MediaPlayer-JNI( 3003): setDataSourceFD: fd 66
V/MediaPlayer( 3003): setDataSource(66, 0, 576460752303423487)
V/MediaPlayerService( 2171): Create new client(35) from pid 3003, uid 10023,
V/MediaPlayerService( 2171): setDataSource fd=35, offset=0, length=576460752303423487
V/MediaPlayerService( 2171): st_dev  = 66317
V/MediaPlayerService( 2171): st_ino  = 267427
V/MediaPlayerService( 2171): st_mode = 33204
V/MediaPlayerService( 2171): st_uid  = 1023
V/MediaPlayerService( 2171): st_gid  = 1023
V/MediaPlayerService( 2171): st_size = 30963
V/MediaPlayerService( 2171): calculated length = 30963

nbastoWM avatar Jan 22 '16 14:01 nbastoWM

OK, new test. I uninstalled the TestGCM app and now my app doesn't catch the if (GcmAndroid.launchNotification) { event if the app is closed. I keep getting the undefined is not an object (evaluating 'RCTToastAndroid.SHORT') but now the console.log GcmAndroid.launchNotification: doesn't show.

I would like to test with the signed APK to exclude problems with connections to the packager, but as mentioned before I can't generate it with this module installed.

nbastoWM avatar Jan 22 '16 15:01 nbastoWM