无法解决符号'编辑'

时间:2017-01-30 19:19:42

标签: java android-studio

我一直在谷歌,这里和其他网站上搜索这个问题的答案,但没有成功。我现在卡住了,无法解决问题。

通常情况下,“无效缓存并重新启动”可以解决问题,“重建项目”,“重新启动程序”或“重新启动计算机”,但似乎它没有与我的项目同步。

在我的Mainactivity中,我可以毫无问题地使用编辑器,但使用我的其他类(在同一文件夹中),我不能使用与以前相同的编辑器方法。

以下是我的代码的几行

    SharedPreferences sharedPreferences = this.getSharedPreferences("com.example.carl.gps.prefs", Context.MODE_PRIVATE);
    sharedPreferences.Editor = sharedPreferences.edit();

    float totalDistanceInMeters = sharedPreferences.getFloat("totalDistanceInMeters", 0f);

    boolean firstTimeGettingPosition = sharedPreferences.getBoolean("firstTimeGettingPosition", true);


    if (firstTimeGettingPosition) {
        editor.putBoolean("firstTimeGettingPosition", false);
    } else {
        Location previousLocation = new Location("");
        previousLocation.setLatitude(sharedPreferences.getFloat("previousLatitude", 0f));
        previousLocation.setLongitude(sharedPreferences.getFloat("previousLongitude", 0f));

        float distance = location.distanceTo(previousLocation);
        totalDistanceInMeters += distance;
        editor.putFloat("totalDistanceInMeters", totalDistanceInMeters);
    }

我遇到的另一个问题是获得此行的许可:

    LocationServices.FusedLocationApi.requestLocationUpdates(
            googleApiClient, locationRequest, this);

我已经声明了以下权限:

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

这在我看来应该足够了,但我对Android Studio有点新意,所以也许我错了。

这是我的依赖项:

    dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.loopj.android:android-async-http:1.4.9'

}

非常感谢我对这些错误的任何帮助。

1 个答案:

答案 0 :(得分:0)

是的,它会向您抛出错误“无法解析编辑器”,因为您必须写 #ifndef F_CPU #define F_CPU 16000000UL #endif #include <avr/io.h> #include <util/delay.h> #include <avr/interrupt.h> #define ACK 0x01 volatile char spi_interupt_flag = 0; void portd_led(void) { // this will blank led in pd7 for 3 sec for(char i=0;i<6;i++){ PORTD^=(1<<PD7) ; // toggle pd7 _delay_ms(500); // you will see 500 ms blank } } int main(void) { DDRB |= (1<<2)|(1<<3)|(1<<5); // SCK, MOSI and SS as outputs DDRB &= ~(1<<4); // MISO as input SPCR |= (1<<MSTR); // Set as Master SPCR |= (1<<SPR0)|(1<<SPR1); // divided clock by 128 SPCR |= (1<<SPIE); // Enable SPI Interrupt SPCR |= (1<<SPE); // Enable SPI DDRC= 0xFF ; // set PORT C as output DDRD = 0xFF ; sei(); spi_send_data(ACK); // this code will make compile error if you not provide a source for implementation while(1){ if (spi_interupt_flag) { //this code only execute when data received from SPI portd_led(); //do whatever you want to do for handle it spi_interupt_flag = 0; //reset the flag again } PORTC^=(1<<PC5); //toggle pc5 for ever _delay_ms(1000); // pc5 will toggle every 1 sec unless ther is interupt } } ISR(SPI_STC_vect) { // just set a flag for handle interrupt in main spi_interupt_flag = 1; } 而不是写这个 sharedPreferences.Editor,希望它能解决您的问题