极光推送初始化失败

这两天项目集成极光推送,在极光官网下载的非常简单的demo,项目是eclipse格式的,在eclipse运行没有问题,但是当我把项目移植到AndroidStudio编译环境之后,居然一直提示初始化失败:
Get registration fail, JPush init failed!
极光推送初始化失败_第1张图片

后来查阅文档,发现几点需要注意的地方,记录一下:
1.项目的applicationID要和你在极光官网申请的应用ID保持一致
2. 因为我没有使用JCenter的自动集成功能,而是直接把so文件和极光jar包复制进了AndroidStudio项目中,需要在gradle配置中添加如下配置:

sourceSets.main {
        jniLibs.srcDirs = ['libs']  // <-- Set your folder here!
    }

极光推送初始化失败_第2张图片
3.注意项目AndroidManifest中的包名要和你的ApplicationID保持一致

"1.0" encoding="utf-8"?>
"http://schemas.android.com/apk/res/android"
    package="您应用的包名"
    android:versionCode="216"
    android:versionName="2.1.6"
    >
    "9" android:targetSdkVersion="23" />

        
        "您应用的包名.permission.JPUSH_MESSAGE"  
            android:protectionLevel="signature" />

    
    "您应用的包名.permission.JPUSH_MESSAGE" />
    "android.permission.RECEIVE_USER_PRESENT" />
    "android.permission.INTERNET" />
    "android.permission.WAKE_LOCK" />
    "android.permission.READ_PHONE_STATE" />
    "android.permission.WRITE_EXTERNAL_STORAGE" />
    "android.permission.READ_EXTERNAL_STORAGE" />
    "android.permission.VIBRATE" />
    "android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
    "android.permission.ACCESS_NETWORK_STATE" />
    "android.permission.WRITE_SETTINGS" /> 
    "android.permission.ACCESS_WIFI_STATE" />

    
    "android.permission.ACCESS_COARSE_LOCATION" />
    "android.permission.CHANGE_WIFI_STATE" />
    "android.permission.ACCESS_FINE_LOCATION" />
    "android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    "android.permission.CHANGE_NETWORK_STATE" />
    "android.permission.GET_TASKS" />

    "@drawable/ic_launcher"
        android:label="@string/app_name"
        android:name="Your Application">

        
        
        
        "cn.jpush.android.service.PushService"
            android:enabled="true"
            android:exported="false" >
            
                "cn.jpush.android.intent.REGISTER" />
                "cn.jpush.android.intent.REPORT" />
                "cn.jpush.android.intent.PushService" />
                "cn.jpush.android.intent.PUSH_TIME" />
            
        

        
        
         "cn.jpush.android.service.DaemonService"
             android:enabled="true"
             android:exported="true">
             
                 "cn.jpush.android.intent.DaemonService" />
                 "您应用的包名"/>
             
         

        
        "cn.jpush.android.service.PushReceiver"
            android:enabled="true" >
          "1000"> 
                "cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> 
                "您应用的包名"/> 
            
            
                "android.intent.action.USER_PRESENT" />
                "android.net.conn.CONNECTIVITY_CHANGE" />
            
            
            
                "android.intent.action.PACKAGE_ADDED" />
                "android.intent.action.PACKAGE_REMOVED" />
                "package" />
            
        
     
        "cn.jpush.android.ui.PushActivity"
            android:configChanges="orientation|keyboardHidden"
            android:exported="false" >
            
                "cn.jpush.android.ui.PushActivity" />
                "android.intent.category.DEFAULT" />
                "您应用的包名" />
            
        
        
        "cn.jpush.android.service.DownloadService"
            android:enabled="true"
            android:exported="false" >
        
        
        "cn.jpush.android.service.AlarmReceiver" />

        
         "您自己定义的Receiver"
             android:enabled="true">
             
                 
                 "cn.jpush.android.intent.REGISTRATION" /> 
                  
                 "cn.jpush.android.intent.MESSAGE_RECEIVED" /> 
                 
                 "cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> 
                 
                 "cn.jpush.android.intent.NOTIFICATION_OPENED" /> 
                 
                 "cn.jpush.android.intent.CONNECTION" />
                 "您应用的包名" />
             
         

        
        
        
        
        
        
        "JPUSH_CHANNEL" android:value="developer-default"/>
        
        "JPUSH_APPKEY" android:value="Your AppKey"/> 
    

你可能感兴趣的:(Android技术)