java.lang.NoClassDefFoundError:org / robolectric / internal / ShadowExtractor

时间:2018-01-06 01:57:29

标签: android google-play-services robolectric

使用

testImplementation 'org.robolectric:shadows-play-services:3.4-rc2'
testImplementation "org.robolectric:robolectric:3.6.1"
testImplementation "com.google.android.gms:play-services-auth:$rootProject.ext.googlePlayServicesVersion" // the robolectric shadow bogusly needs this

我正在尝试这个:

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;

import org.junit.Before;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.gms.Shadows;
import org.robolectric.shadows.gms.common.ShadowGoogleApiAvailability;

@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, shadows = {ShadowGoogleApiAvailability.class})
public abstract class BaseTest {
        @Before
        public void setUp() {
                final ShadowGoogleApiAvailability shadowGoogleApiAvailability
                        = Shadows.shadowOf(GoogleApiAvailability.getInstance());
                final int expectedCode = ConnectionResult.SUCCESS;
                shadowGoogleApiAvailability.setIsGooglePlayServicesAvailable(expectedCode);
        }
}

然而,我的测试失败了这个奇怪的错误:

java.lang.NoClassDefFoundError: org/robolectric/internal/ShadowExtractor
    at org.robolectric.shadows.gms.Shadows.shadowOf(Shadows.java:37)
    at ......BaseTest.setUp(BaseTest.java:19)

我做错了什么,如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

Google Play服务阴影已重命名为

testImplementation 'org.robolectric:shadows-playservices:3.6.1'

根据https://github.com/robolectric/robolectric/issues/3489,这应该与Robolectric 3.5.x一起使用。请注意,官方文档 - http://robolectric.org/using-add-on-modules/ - 尚未更新以反映此更改。

答案 1 :(得分:0)

这已弃用并已删除。切换到import pandas as pd # Read excel file. Use first column as row index, and use first four rows as # column index levels df = pd.read_excel('test.xlsx', index_col=0, header=[0, 1, 2, 3]) # Assign names to row index and column index levels df.index.name = 'PW' df.columns.names = ['Category', 'Field_Type', 'Growing_Method', 'Product'] # Convert all column index levels into row index levels s = df.stack([0, 1, 2, 3]) # Assign name to the single data values column s.name = 'Volume' 。请参阅此问题

stack