安卓:安装 APK 时出错
2022-08-31 17:05:49
我正在慢慢地尝试在.以下应用程序安装在模拟器上,没有任何错误。但是当我尝试将其安装在真实设备上Redmi 3S时,发生了此错误:Android Studio
Unknown failure (Failure - not installed for 0)
Error while Installing APKs
我在这里遇到了类似的问题,但在这些情况下,错误是由未启用调试或未访问应用程序安装引起的。但是,我允许调试,并且我还尝试在Studio中安装其他一些应用程序,并且它工作正常。
所以问题可能是,代码有什么问题。
主要活动.java
package tlacitko.button;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void sendMessage(View view) {
new Thread(new Runnable() {
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
try{
URL url = new URL("http://147.32.186.51:8080");
// HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
InputStream is = url.openStream();
BufferedReader br = new BufferedReader(new
InputStreamReader(is));
String s = "";
}catch(MalformedURLException ex){
}catch(IOException e){
}
}
});
}
}).start();
}
}
和 xml 代码:
activity_main.xml
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Try to connect the server."
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="7dp"
android:layout_marginTop="16dp"
android:onClick="sendMessage"
android:text="Conncect"
app:layout_constraintLeft_toRightOf="@+id/editText"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>