更新库后检测测试失败

时间:2019-07-10 11:22:33

标签: android-gradle android-espresso

我的所有仪器测试都具有以下gradle依赖性:

// USER SETTINGS //////////////////////////////////////////////////////////////////////////////
//


var ROI = geometry;


// Define time range
var startyear = 2010;
var endyear = 2018;

var startmonth = 1 
var endmonth = 12 

var startday = 1 
var endday = 31  



var vis = {min: 10.0,max: 30.0,palette: ['1303ff', '42fff6', 'f3ff40', 'ff5d0f'],};
var vis_D = {min: -2.0,max: 2.0,palette: ['1303ff', '42fff6', 'f3ff40', 'ff5d0f'],};



////////////////////////////////////////////////////////////////////////////////////////////////

var clip = function(img) {return img.clip(ROI);}   
var collection = ee.ImageCollection('NASA/GLDAS/V021/NOAH/G025/T3H')
                    .filterBounds(ROI)
                    .map(clip)
                    .select('Tair_f_inst');


// Set date in ee date format
var startdate = ee.Date.fromYMD(startyear,startmonth,startday);
var enddate = ee.Date.fromYMD(endyear,endmonth,endday).advance(1, 'day');

// create list for years
var years = ee.List.sequence(startyear,endyear);

// create list for months
var months = ee.List.sequence(startmonth,endmonth);

// get days in month
function getDaysInMonth(y,m) {
  var dt = ee.Date.fromYMD(y,m,1);
  var n = dt.advance(1,"month").difference(dt,'day');
  return ee.List.sequence(1,n);
}

// get days in month for AVG
function getDaysInMonth2(m) {
  var dt = ee.Date.fromYMD(1970,m,1);
  var n = dt.advance(1,"month").difference(dt,'day');
  return ee.List.sequence(1,n);
}

//get projection of the dataset
var proj = ee.Image(collection.first()).projection();



// Filter data
var datain = collection.filterDate(startdate, enddate)
  // .filter(ee.Filter.calendarRange(startmonth,endmonth, 'month'))


// convert to Celsius
var datain = datain.select('Tair_f_inst').map(function(image) {
  return image.subtract(273.15).rename('tmp')
  .set('system:time_start', image.get('system:time_start'))
  .set('doy', image.date().format('YYYY-MM-dd'))
})
// print(datain,'datain')



// aggregate hourly to daily
var daily =  ee.ImageCollection.fromImages(
  years.map(function (y) {
     return months.map(function(m) {
        var days = getDaysInMonth(y,m) 
        return days.map(function(d) {
          var filtered_Daily = datain.filter(ee.Filter.calendarRange(y, y, 'year'))
                    .filter(ee.Filter.calendarRange(m, m, 'month'))
                    .filter(ee.Filter.calendarRange(d, d, 'day_of_month'))
                    .max();
        return filtered_Daily.set('year', y)
              .set('month', m)
              .set('day', d)
              .set('date', ee.Date.fromYMD(y, m, d))
              .set('system:time_start', ee.Date.fromYMD(y, m, d).millis());

    });
    });
  }).flatten()
);

// print (daily,'daily');
// Map.addLayer(daily.first(), vis,'Air_Tmp');



var daily_LTA =  ee.ImageCollection.fromImages(
     months.map(function(m) {
        var days = getDaysInMonth2(m) 
        return days.map(function(d) {
          var filtered_Daily = datain
                    .filter(ee.Filter.calendarRange(m, m, 'month'))
                    .filter(ee.Filter.calendarRange(d, d, 'day_of_month'))
                    .mean()
                    .rename('tmp_LTA');
        return filtered_Daily.set('year', 1970)
              .set('month', m)
              .set('day', d)
              .set('date', ee.Date.fromYMD(1970, m, d))
              .set('system:time_start', ee.Date.fromYMD(1970, m, d).millis());

    });
  }).flatten()
);

print (daily_LTA,'daily_LTA');
Map.addLayer(daily_LTA.first(), vis,'Air_Tmp_LTA');

一旦我将它们更新为:

    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.0'
    androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.1.0'
    implementation 'androidx.test.espresso:espresso-idling-resource:3.1.0'

    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test:rules:1.1.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    debugImplementation 'androidx.fragment:fragment-testing:1.2.0-alpha01'
    implementation 'androidx.fragment:fragment:1.1.0-alpha01'
    androidTestImplementation 'org.mockito:mockito-android:2.24.5'

并运行测试,出现以下错误:

  

找不到满足以下条件的'androidx.test:core'版本   版本限制:

     

依赖路径'my_package_name:app:unspecified'->   'androidx.test.espresso:espresso-intents:3.2.0'->   'androidx.test:core:1.2.0'

....等等,有很多行

我该如何解决?为什么会发生?

1 个答案:

答案 0 :(得分:2)

为什么会这样?

发生这种情况是因为androidx.test:core:1.2.0的版本冲突:

依赖项androidx.test.espresso:espresso-intents:3.2.0使用核心库的1.2.0版本。虽然有另一个依赖项使用同一库的另一个版本,这使Gradle不满意。如果您继续阅读这些很多行,您会看到另一个依赖项是什么,但我高度怀疑它是androidx.fragment:fragment-testing:1.2.0-alpha01,它取决于1.1.1版核心库。

解决方法:

鉴于您确实需要升级意式浓缩咖啡,并假设有问题的库正在片段测试中,一个简单的解决方法是更改​​

debugImplementation 'androidx.fragment:fragment-testing:1.2.0-alpha01'

debugImplementation ("androidx.fragment:fragment-testing:1.2.0-alpha01", {exclude group: 'androidx.test', module: 'core' })