我一直在试图在Youtube上关注教程视频。当我尝试在模拟器中查看它时,他会在他的视频中看到以下错误。如何解决“错误:';'预计“Android Studio中的错误?
Error:(22, 48) error: ';' expected
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
我已经做了一个快速的网络搜索,并且人们建议检查JDK文件的位置。我已经做到了这一点,但没有帮助。这是我的JDK位置。
C:\Program Files\Java\jdk1.8.0_121
这是我从教程中复制的一小段代码。
package shmaves.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.RelativeLayout;
import android.widget.Button;
import android.graphics.Color;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//layout
RelativeLayout shmavesLayout = new RelativeLayout(this);
shmavesLayout.setBackgroundColor(Color.GREEN);
//Button
Button redButton = new Button (this);
redButton.setText ("click me");
redButton.setBackgroundColor(Color.RED)
//Add widget to layout (button is now a child of layout
shmavesLayout.addView(redButton);
//Set this activities content/display to this view
setContentView(shmavesLayout);
}
}
任何人都可以摆脱一些光线或看看我哪里出了错?我对这一切都很陌生,所以请详细解释。
这工作。谢谢!我不知道这是什么意思。 – Shmaves