错误:无法找到或加载主类org.gradle.wrapper.GradleWrapperMain

时间:2017-04-20 13:52:49

标签: react-native android-gradle react-native-android

我已经反应了原生版本0.42.0。我的项目工作正常。

最近我升级到react-native版本0.43.1。现在我做的时候

react-native run-android

我遇到了错误。

JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

我已按照升级说明进行操作 https://facebook.github.io/react-native/docs/upgrading.html

我用Google搜索了这个问题。通过以下链接,没有一个对我有用。

  1. Could not find or load main class org.gradle.wrapper.GradleWrapperMain

  2. Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

  3. How/when to generate Gradle wrapper files?

  4. 任何形式的帮助/指导对我都有帮助。

5 个答案:

答案 0 :(得分:8)

请检查gradle/wrapper文件夹中的 gradle-wrapper.jar

我得到了和你一样的错误,我用完整的一个改变了jar。

我还使用*distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip更改了 gradle-wrapper.properties 文件中的一行, gradle将自行下载。

答案 1 :(得分:8)

import pandas as pd
import numpy as np

df = pd.DataFrame(dict(
    obj=[['Boeing'], ['aircrafts', 'they', 'agreement', 'airplane'], ['exception', 'these']],
    rel1=[['sells'], ['are', 'built',  'made',  'built'],['are', 'are']],
    dep1=[['aircrafts'], [], []],
    rel2=[['to'], ['on', 'with'], ['of', 'of', 'for']]
))

# Output dataframe
out = pd.DataFrame()

# Keep track of which set of rows we have already appended to the dataframe
row_counter = 0

# Loop through each row in the input dataframe
for row, value in df.iterrows():

    # Get the max len of each list in this row
    rows_needed = value.map(lambda x: len(x)).max()

    for i in range(rows_needed):

        # Set a name for this row (numeric)
        new_row = pd.Series(name=row_counter+i)

        # Loop through each header and create a single row per item in the list
        for header in value.index:

            # Find if there will be a value here or null
            this_value = np.nan
            if i < len(df.loc[row, header]):
                this_value = df.loc[row, header][i]

            # Add this single result to a series for this row
            new_row = new_row.set_value(header, this_value)

        # Add this row series to the full dataframe
        out = out.append(new_row)
    row_counter += rows_needed

out
Out[1]:
        dep1        obj   rel1  rel2
0  aircrafts     Boeing  sells    to
1        NaN  aircrafts    are    on
2        NaN       they  built  with
3        NaN  agreement   made   NaN
4        NaN   airplane  built   NaN
5        NaN  exception    are    of
6        NaN      these    are    of
7        NaN        NaN    NaN   for

order = ['obj', 'rel1', 'dep1', 'rel2']
out = out[order]
out
Out[2]:
         obj   rel1       dep1  rel2
0     Boeing  sells  aircrafts    to
1  aircrafts    are        NaN    on
2       they  built        NaN  with
3  agreement   made        NaN   NaN
4   airplane  built        NaN   NaN
5  exception    are        NaN    of
6      these    are        NaN    of
7        NaN    NaN        NaN   for

运行此命令可能会解决您的问题。就我而言,确实如此。但请确保备份Android和iOS文件夹,以防您进行修改。

答案 2 :(得分:2)

  1. 从〜\ android \ gradle \ wrapper检查你的gradle-wrapper.jar文件大小,可用的jar文件大小为49 KB

  2. 更新您的gradle-wrapper.properties文件distributionUrl = https://services.gradle.org/distributions/gradle-2.10-all.zip

  3. 添加 任务包装器(类型:包装器){ gradleVersion =&#39; 2.10&#39; } 在build.gradle上

  4. 再次,运行react-native run-android。如果您收到此错误:

     * What went wrong: Execution failed for task ':app:mergeDebugResources'.
     > Some file crunching failed, see logs for details ,
    

    请添加build.gradle

    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.1"
    
        aaptOptions {
            cruncherEnabled = false
            useNewCruncher = false
        }
    

答案 3 :(得分:2)

我通过以下两个简单步骤解决了此问题:

1)删除Android和iOS文件夹

2)执行下一行

react-native eject

3)跑!

react-native run-android

答案 4 :(得分:0)

您的环境中可能没有gradle设置。 您可以点击下面的链接配置gradle,然后再次运行gradle包装器。

按照以下链接中的说明进行操作。 https://gradle.org/install/#manually