Android React Native错误“找不到support-annotations.jar”

时间:2017-02-01 16:19:53

标签: android react-native onesignal

我有一个react-native应用程序,当尝试在android上运行或编译apk时,我收到此错误:

react-native run-android
Starting JS server...
Running C:\Users\David\AppData\Local\Android\sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && gradlew.bat installDebug)...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-onesignal'.
   > Could not find support-annotations.jar (com.android.support:support-annotations:24.0.0).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/support/support-annotations/24.0.0/support-annotations-24.0.0.jar

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

BUILD FAILED

我已尝试使用另一台机器,但它可以正常工作,但不能在我的电脑中使用。我已经检查了版本,而且每件事都可以。我正在运行Windows 10。

这是我的配置:

Application package.json

{
  "name": "MyApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "dependencies": {
    "@remobile/react-native-toast": "^1.0.5",
    "moment": "^2.17.1",
    "native-base": "^0.5.22",
    "react": "^15.4.0",
    "react-native": "^0.40.0",
    "react-native-android-location-services-dialog-box": "^1.1.8",
    "react-native-facebook-login": "^1.4.0",
    "react-native-gifted-listview": "0.0.15",
    "react-native-google-location-fixed": "^0.2.0",
    "react-native-lightbox-android": "^0.6.0",
    "react-native-loading-spinner-overlay": "^0.3.0",
    "react-native-modal-dropdown": "^0.4.1",
    "react-native-onesignal": "^3.0.0",
    "react-native-side-menu-fixed": "^0.20.1",
    "react-native-vector-icons": "^4.0.0"
  }
}

应用程序版本:

> java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

> npm -v
4.1.2

> node -v
v6.9.4

> sdkmanager.bat --list
Installed packages:
  Path                              | Version | Description                       | Location
  -------                           | ------- | -------                           | -------
  build-tools;23.0.1                | 23.0.1  | Android SDK Build-Tools 23.0.1    | build-tools\23.0.1\
  build-tools;23.0.2                | 23.0.2  | Android SDK Build-Tools 23.0.2    | build-tools\23.0.2\
  build-tools;25.0.2                | 25.0.2  | Android SDK Build-Tools 25.0.2    | build-tools\25.0.2\
  docs                              | 1       | Documentation for Android SDK     | docs\
  extras;android;m2repository       | 42.0.0  | Android Support Repository, re... | extras\android\m2repository\
  extras;google;g...e_play_services | 38.0.0  | Google Play services, rev 38      | extras\google\g..._play_services\
  extras;google;m2repository        | 42.0.0  | Google Repository, rev 42         | extras\google\m2repository\
  extras;google;usb_driver          | 11.0.0  | Google USB Driver, rev 11         | extras\google\usb_driver\
  extras;intel;Ha...ecution_Manager | 6.0.5   | Intel x86 Emulator Accelerator... | extras\intel\Ha...cution_Manager\
  extras;m2reposi...ver;1.0.0-beta4 | 1       | Solver for ConstraintLayout 1.... | extras\m2reposi...er\1.0.0-beta4\
  extras;m2reposi...out;1.0.0-beta4 | 1       | ConstraintLayout for Android 1... | extras\m2reposi...ut\1.0.0-beta4\
  patcher;v1                        | 1       | SDK Patch Applier v1              | patcher\v1\
  patcher;v3                        | 1       | SDK Patch Applier v3              | patcher\v3\
  patcher;v4                        | 1       | SDK Patch Applier v4              | patcher\v4\
  platform-tools                    | 25.0.3  | Android SDK Platform-Tools        | platform-tools\
  platforms;android-16              | 5       | Android SDK Platform 16, rev 5    | platforms\android-16\
  platforms;android-21              | 2       | Android SDK Platform 21           | platforms\android-21\
  platforms;android-22              | 2       | Android SDK Platform 22           | platforms\android-22\
  platforms;android-23              | 3       | Android SDK Platform 23           | platforms\android-23\
  platforms;android-24              | 2       | Android SDK Platform 24, rev 2    | platforms\android-24\
  platforms;android-25              | 3       | Android SDK Platform 25           | platforms\android-25\
  sources;android-21                | 1       | Sources for Android 21            | sources\android-21\
  sources;android-22                | 1       | Sources for Android 22            | sources\android-22\
  sources;android-23                | 1       | Sources for Android 23            | sources\android-23\
  sources;android-24                | 1       | Sources for Android 24            | sources\android-24\
  sources;android-25                | 1       | Sources for Android 25            | sources\android-25\
  system-images;a...-16;default;x86 | 5       | Intel x86 Atom System Image       | system-images\a...16\default\x86\
  system-images;a...gle_apis;x86_64 | 12      | Google APIs Intel x86 Atom_64 ... | system-images\a...le_apis\x86_64\
  system-images;a...google_apis;x86 | 19      | Google APIs Intel x86 Atom Sys... | system-images\a...oogle_apis\x86\
  system-images;a...;android-tv;x86 | 9       | Android TV Intel x86 Atom Syst... | system-images\a...android-tv\x86\
  system-images;a...ear;armeabi-v7a | 2       | Android Wear ARM EABI v7a Syst... | system-images\a...ar\armeabi-v7a\
  tools                             | 25.2.5  | Android SDK Tools 25.2.5          | tools\

1 个答案:

答案 0 :(得分:0)

似乎这是一个带有gradle的版本错配。在build.gradle和gradle-wrapper.properties中更新它似乎有效。

diff --git a/android/build.gradle b/android/build.gradle
index 46047bd..1ec7ade 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -5,7 +5,7 @@ buildscript {
         jcenter()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.1.0'
+        classpath 'com.android.tools.build:gradle:2.2.2' // Upgrade gradle

         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index 9851e51..625125b 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
+distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip

但我仍然不知道为什么在另一台机器上工作......

https://github.com/geektimecoil/react-native-onesignal/issues/175