在android studio中找不到com.android.tools.build:gradle-experimental:3.4.0

时间:2019-05-16 13:13:17

标签: android android-gradle

我的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com/"
        }
    }
    dependencies {
        //classpath 'com.android.tools.build:gradle:2.1.2'
//        classpath 'com.android.tools.build:gradle-experimental:0.7.2'
        classpath 'com.android.tools.build:gradle:3.4.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
repositories {
    mavenCentral()
    mavenLocal()
}

allprojects {
    repositories {
        mavenCentral()
        mavenLocal()
        jcenter()
        maven {
            url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

并且出现同步错误,如下所示

ERROR: Could not find com.android.tools.build:gradle-experimental:3.4.0.
Searched in the following locations:
  - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle-experimental/3.4.0/gradle-experimental-3.4.0.pom
  - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle-experimental/3.4.0/gradle-experimental-3.4.0.jar
  - https://jcenter.bintray.com/com/android/tools/build/gradle-experimental/3.4.0/gradle-experimental-3.4.0.pom
  - https://jcenter.bintray.com/com/android/tools/build/gradle-experimental/3.4.0/gradle-experimental-3.4.0.jar
  - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle-experimental/3.4.0/gradle-experimental-3.4.0.pom
  - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle-experimental/3.4.0/gradle-experimental-3.4.0.jar
Required by:
    project :app

所有类路径都不起作用

我该如何解决?

3 个答案:

答案 0 :(得分:0)

您可能需要在gradle-wrapper.properties中更改“ distributionURL”。

在此page中,您可以看到所需的gradle版本。 在您的示例中,我认为这将是“ distributionURL”:

distributionUrl = https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

答案 1 :(得分:0)

答案 2 :(得分:0)

在build.gradle的存储库列表中添加google()。

import React from 'react';
import { Platform } from 'react-native';
import { createStackNavigator, createBottomTabNavigator } from 'react-navigation';

import TabBarIcon from '../components/TabBarIcon';
import SettingsScreen from '../screens/SettingsScreen';
import {getBrowerScreen} from '../screens/BrowserScreen';


const SettingsStack = createStackNavigator({
  Settings: SettingsScreen,
});

SettingsStack.navigationOptions = {
  tabBarLabel: 'Settings',
  tabBarIcon: ({ focused }) => (
    <TabBarIcon
      focused={focused}
      name={Platform.OS === 'ios' ? 'ios-options' : 'md-options'}
    />
  ),
};

// Tab params that we will get from API
var tabParams = [
  {title: 'Tab 1', url: 'https://mycar.city', icon: 'md-pricetags'},
  {title: 'Tab 2', url: 'https://mycar.city', icon: 'ios-play-circle'},
  {title: 'Tab 3', url: 'https://mycar.city', icon: 'ios-phone-portrait'},
  {title: 'Tab 4', url: 'https://global-trend.info', icon: 'ios-phone-portrait'},
],
tabs = {};

for (var i=0; i<tabParams.length; i++) {
  const tab = tabParams[i];

  tabs['Tab' + (i + 1)] = createStackNavigator({
    Links: getBrowerScreen(tab.url),
  });

  tabs['Tab' + (i + 1)].navigationOptions = {
    tabBarLabel: tab.title,
    tabBarIcon: ({ focused }) => (
      <TabBarIcon
        focused={focused}
        name={tab.icon}
      />
    ),
  };
}

//Adding another kind of tab
tabs.SettingsStack = SettingsStack;

export default createBottomTabNavigator(tabs);