我破坏了 Android 工作室吗?
Did I break Android Studio?
一周前,我成功地使用了 ListView,每次单击按钮时都会向其中添加一个项目。然后我发现我需要把一些东西放在一个线程中 separate from the main UI thread,在这个过程中的某个地方,有些东西坏了。
现在我每次启动 Android Studio 时都会看到一个错误,说 FileNotFoundException: Entry fileTemplates//code/Google Test Fixture SetUp Method.cc.ft not found in E:/Programs/Android Studio/lib/idea.jar
不过我转到了那个文件夹,我可以看到该文件存在。 This 是我最接近解决问题的方法。
我也尝试过冷重启我的计算机和我的 phone,重新安装 Android Studio,创建一个全新的项目,然后文件 > 使缓存无效并重新启动,none 其中有帮助。
我能找到的唯一其他答案是因为它是 32 位系统上的 64 位版本。我敢肯定情况并非如此,除非我在专门寻找 32 位的同时以某种方式下载了 64 位。
我不知道这是否是 Android Studio 的问题,Gradle,与我用作测试平台的 phone 有关,还是什么。
我正在使用:
Windows 8.1 专业版(32 位)
2 个奔腾 3.2 GHz (x64)
Android Studio 2.3.3
API15 的最低 SDK:Android4.0.3 IceCreamSandwich
Java v1.8.0_144(根据命令提示符中的 "java -version")
Java 8 更新 60 和 144 在我的已安装程序列表中,以及 Java SE 开发工具包 8 更新 60 和 144
这是我提到的新项目的代码:
MainActivity.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
ArrayList<String> listItems;
ArrayAdapter<String> adapter;
ListView listview = (ListView) findViewById(R.id.listview);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listItems = new ArrayList<>();
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems);
listview.setAdapter(adapter);
}
public void sendAnother(View view) {
adapter.add("button clicked");
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="meh.myapplication.MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Testing"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<ListView
android:id="@+id/listview"
android:layout_width="0dp"
android:layout_height="431dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="@+id/button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
事实证明,我做错的只是试图在 onCreate() 之前初始化 listview。声明它很好,但初始化会破坏它。我想,尽管在 xml 中定义了视图对象,但直到运行时才实例化?
我有一个在任何东西坏掉之前做的备份,但它也坏了。或者,现在我又把它弄乱了,部分损坏了。 (按钮不起作用,但我可以输出到列表视图)我想我认为这意味着 Android Studio 可能 中的某些内容已被破坏。我想这就是为什么我没有注意到我尝试初始化 listview 的地方有所不同的原因。
我想如果你用锤子敲得够久,任何石头都会碎,嗯?
一周前,我成功地使用了 ListView,每次单击按钮时都会向其中添加一个项目。然后我发现我需要把一些东西放在一个线程中 separate from the main UI thread,在这个过程中的某个地方,有些东西坏了。
现在我每次启动 Android Studio 时都会看到一个错误,说 FileNotFoundException: Entry fileTemplates//code/Google Test Fixture SetUp Method.cc.ft not found in E:/Programs/Android Studio/lib/idea.jar
不过我转到了那个文件夹,我可以看到该文件存在。 This 是我最接近解决问题的方法。
我也尝试过冷重启我的计算机和我的 phone,重新安装 Android Studio,创建一个全新的项目,然后文件 > 使缓存无效并重新启动,none 其中有帮助。
我能找到的唯一其他答案是因为它是 32 位系统上的 64 位版本。我敢肯定情况并非如此,除非我在专门寻找 32 位的同时以某种方式下载了 64 位。
我不知道这是否是 Android Studio 的问题,Gradle,与我用作测试平台的 phone 有关,还是什么。
我正在使用:
Windows 8.1 专业版(32 位)
2 个奔腾 3.2 GHz (x64)
Android Studio 2.3.3
API15 的最低 SDK:Android4.0.3 IceCreamSandwich
Java v1.8.0_144(根据命令提示符中的 "java -version")
Java 8 更新 60 和 144 在我的已安装程序列表中,以及 Java SE 开发工具包 8 更新 60 和 144
这是我提到的新项目的代码:
MainActivity.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
ArrayList<String> listItems;
ArrayAdapter<String> adapter;
ListView listview = (ListView) findViewById(R.id.listview);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listItems = new ArrayList<>();
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems);
listview.setAdapter(adapter);
}
public void sendAnother(View view) {
adapter.add("button clicked");
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="meh.myapplication.MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Testing"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<ListView
android:id="@+id/listview"
android:layout_width="0dp"
android:layout_height="431dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="@+id/button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
事实证明,我做错的只是试图在 onCreate() 之前初始化 listview。声明它很好,但初始化会破坏它。我想,尽管在 xml 中定义了视图对象,但直到运行时才实例化?
我有一个在任何东西坏掉之前做的备份,但它也坏了。或者,现在我又把它弄乱了,部分损坏了。 (按钮不起作用,但我可以输出到列表视图)我想我认为这意味着 Android Studio 可能 中的某些内容已被破坏。我想这就是为什么我没有注意到我尝试初始化 listview 的地方有所不同的原因。
我想如果你用锤子敲得够久,任何石头都会碎,嗯?