- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个正在运行的 iOS React Native 应用程序(React Native v 0.38)。我也尝试在 android 中运行相同的应用程序。 我已经手动链接了所有这些库(我现在在 iOS 中使用):
react-native-camera
react-native-code-push
react-native-device-info
react-native-google-analytics-bridge
react-native-i18n
react-native-push-notification
react-native-restart
react-native-sqlite-storage
设置.gradle :
include ':app'
include ':react-native-sqlite-storage'
project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')
include ':react-native-restart'
project(':react-native-restart').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-restart/android')
include ':react-native-push-notification'
project(':react-native-push-notification').projectDir = file('../node_modules/react-native-push-notification/android')
include ':app', ':react-native-i18n'
project(':react-native-i18n').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-i18n/android')
include ':react-native-google-analytics-bridge', ':app'
project(':react-native-google-analytics-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-analytics-bridge/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
构建.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
Android/app/build.gradle :
apply plugin: "com.android.application"
import com.android.build.OutputFile
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.opencampus"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':react-native-sqlite-storage')
compile project(':react-native-restart')
compile project(':react-native-push-notification')
compile ('com.google.android.gms:play-services-gcm:9.8.0') {
force = true;
}
compile project(':react-native-i18n')
compile project(':react-native-google-analytics-bridge')
compile project(':react-native-device-info')
compile project(':react-native-code-push')
compile project(':react-native-camera')
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
安卓 list :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.opencampus"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
</application>
</manifest>
主应用程序.java :
package com.opencampus;
import android.app.Application;
import android.util.Log;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
import com.avishayil.rnrestart.ReactNativeRestartPackage;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
import com.i18n.reactnativei18n.ReactNativeI18n;
import com.idehub.GoogleAnalyticsBridge.GoogleAnalyticsBridgePackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.microsoft.codepush.react.CodePush;
import com.lwansbrough.RCTCamera.RCTCameraPackage;
import org.pgsqlite.SQLitePluginPackage;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
// 2. Override the getJSBundleFile method in order to let
// the CodePush runtime determine where to get the JS
// bundle location from on each app start
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new SQLitePluginPackage(),
new MainReactPackage(),
new ReactNativePushNotificationPackage(),
new ReactNativeI18n(),
new GoogleAnalyticsBridgePackage(),
new RNDeviceInfo(),
new CodePush("-", MainApplication.this, BuildConfig.DEBUG),
new RCTCameraPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
有什么解决办法吗?
最佳答案
我发现了问题。在 MainApplication.java 中,new MainReactPackage() 被包含了两次。
package com.opencampus;
import android.app.Application;
import android.util.Log;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
import com.avishayil.rnrestart.ReactNativeRestartPackage;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
import com.i18n.reactnativei18n.ReactNativeI18n;
import com.idehub.GoogleAnalyticsBridge.GoogleAnalyticsBridgePackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.microsoft.codepush.react.CodePush;
import com.lwansbrough.RCTCamera.RCTCameraPackage;
import org.pgsqlite.SQLitePluginPackage;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
// 2. Override the getJSBundleFile method in order to let
// the CodePush runtime determine where to get the JS
// bundle location from on each app start
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new SQLitePluginPackage(),
new MainReactPackage(), **<<<<< **** included two times**
new ReactNativePushNotificationPackage(),
new ReactNativeI18n(),
new GoogleAnalyticsBridgePackage(),
new RNDeviceInfo(),
new CodePush("-", MainApplication.this, BuildConfig.DEBUG),
new RCTCameraPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
关于javascript - react native : Native module AppStateModule tried to override AppStateModule for module name AppState,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40992548/
有没有在OpenJDK 1.7.0_45中派生类重写基类方法,但没有@Override注解,运行时派生类实例调用基类方法的情况? class Base { public f() { }
我正在尝试在 C++ 中练习 OOP,但我遇到了有关覆盖函数的问题。在我的 Shape2D 和 Shape3D 类中,我有在 Square 和 Sphere 类(分别为 ShowArea() 和 Sh
我想控制值在槽中的保存方式以及读取槽时返回的内容。这是我的类定义: (defclass object () ((name :accessor name-access :initf
我正在尝试在 C++ 中练习 OOP,但我遇到了有关覆盖函数的问题。在我的 Shape2D 和 Shape3D 类中,我有在 Square 和 Sphere 类(分别为 ShowArea() 和 Sh
我读了section在 Scala 编程中,引入了抽象重写,但我仍然对这些修饰符的连接到底意味着什么感到困惑。使用这些修饰符的代码片段粘贴在下面: trait Doubling extends Int
阅读Javadoc对于 @Override 注释,我遇到了以下规则: If a method is annotated with thisannotation type compilers are r
我正在基于 BEP20Token 模板 (https://github.com/binance-chain/bsc-genesis-contract/blob/master/contracts/bep
关于下面提到的 3 份契约(Contract): 1) Whenever hashCode() is invoked on the same object more than once during
在 C# 中,override 默认启用,那么,是否不需要显式在基类中将方法声明为可覆盖?如果是的话 Overridable 仅限于 VB.NET 还是在 C# 中也是必需的? 因此可以覆盖哪些类型的
以下代码在 public void onClick 行生成此错误消息。 Multiple markers at this line - implements android.view.View.OnC
当我在运行 IIS 的服务器 2012R2 上托管它时,我能够使用 Autorest 和我的 api 生成代码 但是,当我尝试使用 localhost url 运行它时,我收到一条无法读取的消息。 我
代码如下。 IDE 的代码没问题,但 gradle 拒绝构建,并表示: TextAdapter is not abstract and does not override abstract metho
这个问题已经有答案了: Best practice for overriding classes / properties in ExtJS? (3 个回答) 已关闭 8 年前。 这两个覆盖有什么区别
我今天将 xcode 更新为 7。更新后,我正在处理的项目出现警告“覆盖成员函数但未标记为‘覆盖’”。由于我们的项目将“踩踏警告为错误”设置为true。我遇到了很多错误。 我仔细检查了“Other L
我试图将 Apple 的 ARKit 示例应用程序集成到我的应用程序中。由于 ARKit 只是一个附加功能,所以我需要支持较低版本的 iOS。我在所有 ARKit 示例应用程序类中添加了 @avail
我覆盖了类的 Equals() 来比较 Guid 类型的 ID 值。 然后 Visual Studio 警告: ... overrides Object.Equals(object o) but do
我正在尝试用 Java 中的 Runnable 对象创建一个基本线程。下面是我的代码: import java.lang.Thread; import java.lang.Runnable; publ
我有一个函数: int function(int a, int b = 1, int c = 2){ return a+b+c; } 我想将“c”变量的值设置为3,但不想设置“b”的值 在像
我正在尝试了解GAS的.code16行为。 在手册中,对于16位部分,对于32位操作数或指令,似乎会为指令编码生成一个66H操作数替代前缀。这是否意味着 .code16 movw %eax, %ebx
我正在尝试创建一个 JFrame,向 JFrame 添加一个 JLabel(image),但这需要我抛出 IOException,这会弄乱我的 main 方法中的 run() 。 谁能告诉我如何抛出异
我是一名优秀的程序员,十分优秀!