 |
|
รัน apk โดยใช้ android studio ผลลัพธ์ได้ error ตามข้างล่าง เมื่อดู code ไม่มีอะไร error สีแดงขึ้นทุกบรรทัด ปัญหานี้ควรแก้ไขอย่างไร
Code
Information:Gradle tasks [:app:assembleDebug]
Error:trouble processing "java/awt/font/NumericShaper.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
Error:going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error:from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.
Error:1 error; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --force-jumbo --num-threads=4 --multi-dex --output D:\Android\MyApplication\app\build\intermediates\transforms\dex\debug\folders\1000\2\android-3.1_be4ac94dd1bb49eef4fb269638f5d238e8794afb D:\Android\MyApplication\app\libs\android-3.1.jar}
Information:BUILD FAILED
Code (Android-Java)
MyActivity.java
package com.myapplication;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public class MyActivity extends Activity implements OnClickListener {
Button btn_select;
TextView tv_res;
EditText txt_hn;
EditText txt_name;
EditText txt_age;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_my);
tv_res = (TextView)findViewById(R.id.tv_res);
txt_hn = (EditText)findViewById(R.id.txt_hn);
txt_name = (EditText)findViewById(R.id.txt_name);
txt_age = (EditText)findViewById(R.id.txt_age);
btn_select = (Button)findViewById(R.id.btn_select);
btn_select.setOnClickListener(this);
}
@Override
public void onClick(View v){
switch(v.getId()){
case R.id.btn_select:
{
select();
break;
}
}
}
public void clsText(){
txt_hn.setText("");
txt_name.setText("");
txt_age.setText("");
}
public void select() {
tv_res.setText("");
InputStream is = null;
String js_result = "";
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://localhost/testAndroid/get_data.php");
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
Log.d("log_err", "Error in http connection " + e.toString());
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
is.close();
js_result = sb.toString();
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}
try {
final JSONArray jArray = new JSONArray(js_result);
for (int i = 0; i < jArray.length(); i++) {
JSONObject jo = jArray.getJSONObject(i);
String hn = jo.getString("hn");
String name = jo.getString("name");
String age = String.valueOf(jo.getInt("age"));
String date_serv = jo.getString("date_serv");
Log.d("log",hn+","+name+","+age+","+date_serv);
tv_res.append(hn+","+name+","+age+","+date_serv+"\n");
}
} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
}
}
Code (XML)
activity_main_my.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MyActivity">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Connect To Mysql Example" />
<EditText
android:id="@+id/txt_hn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="HN" >
</EditText>
<EditText
android:id="@+id/txt_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name-Lastname" />
<EditText
android:id="@+id/txt_age"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Age" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/btn_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select" />
</LinearLayout>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
<TextView
android:id="@+id/tv_res"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" ></LinearLayout>
</ScrollView>
</LinearLayout>
Tag : Mobile
|
|
 |
 |
 |
 |
Date :
2017-06-23 16:41:57 |
By :
mininova |
View :
2254 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |