Friday 15 April 2011

java - My App wont compile and when it throws an error all my resource files are gone -



java - My App wont compile and when it throws an error all my resource files are gone -

for reason whenver seek compile android studio project, keeps saying image "default" invalid. doesn't create sense because in xml file has no issue displaying when alter view design mode view. after compile, gradle throws issue , "r." turn symbol not found. i.e. whever did r.id.textview, r's turn reddish , can't alter back.

my errors:

error:error: invalid symbol: 'default' error:execution failed task ':app:processdebugresources'. > com.android.ide.common.internal.loggederrorexception: failed run command: /applications/android studio.app/sdk/build-tools/android-4.4w/aapt bundle -f --no-crunch -i /applications/android studio.app/sdk/platforms/android-20/android.jar -m /users/anuraag/androidstudioprojects/weather/app/build/intermediates/manifests/debug/androidmanifest.xml -s /users/anuraag/androidstudioprojects/weather/app/build/intermediates/res/debug -a /users/anuraag/androidstudioprojects/weather/app/build/intermediates/assets/debug -m -j /users/anuraag/androidstudioprojects/weather/app/build/generated/source/r/debug -f /users/anuraag/androidstudioprojects/weather/app/build/intermediates/libs/app-debug.ap_ --debug-mode --custom-package com.anuraagy.weather -0 apk error code: 1 output: res/drawable-hdpi-v4/default.png:0: error: invalid symbol: 'default'

main activity

package com.anuraagy.weather; import android.app.activity; import android.app.actionbar; import android.app.fragment; import android.os.asynctask; import android.os.bundle; import android.util.log; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.os.build; import org.apache.http.httpresponse; import org.apache.http.httpstatus; import org.apache.http.statusline; import org.apache.http.client.clientprotocolexception; import org.apache.http.client.httpclient; import org.apache.http.client.methods.httpget; import org.apache.http.impl.client.defaulthttpclient; import java.io.bytearrayoutputstream; import java.io.ioexception; public class myactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_my); if (savedinstancestate == null) { getfragmentmanager().begintransaction() .add(r.id.container, new placeholderfragment()) .commit(); } } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.my, menu); homecoming true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); if (id == r.id.action_settings) { homecoming true; } homecoming super.onoptionsitemselected(item); } /** * placeholder fragment containing simple view. */ public static class placeholderfragment extends fragment { public placeholderfragment() { } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_my, container, false); requesttask task = new requesttask(); task.execute(new string[]{"http://stackoverflow.com"}); homecoming rootview; } } public static class requesttask extends asynctask<string, string, string> { @override protected string doinbackground(string... uri) { httpclient httpclient = new defaulthttpclient(); httpresponse response; string responsestring = null; seek { response = httpclient.execute(new httpget(uri[0])); statusline statusline = response.getstatusline(); if(statusline.getstatuscode() == httpstatus.sc_ok){ bytearrayoutputstream out = new bytearrayoutputstream(); response.getentity().writeto(out); out.close(); responsestring = out.tostring(); } else{ //closes connection. response.getentity().getcontent().close(); throw new ioexception(statusline.getreasonphrase()); } } grab (clientprotocolexception e) { //todo handle problems.. } grab (ioexception e) { //todo handle problems.. } log.i("",responsestring); homecoming responsestring; } @override protected void onpostexecute(string result) { super.onpostexecute(result); //do response.. } } }

my xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".myactivity$placeholderfragment"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageview" android:src="@drawable/default" android:layout_alignparenttop="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true" /> <!--<textview--> <!--android:layout_width="wrap_content"--> <!--android:layout_height="wrap_content"--> <!--android:textappearance="?android:attr/textappearancelarge"--> <!--android:text="80&#xb0;f"--> <!--android:id="@+id/textview2"--> <!--android:textsize="90sp"--> <!--android:layout_aligntop="@+id/imageview"--> <!--android:layout_alignright="@+id/textview3"--> <!--android:layout_alignend="@+id/textview3" />--> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="it's sunny. now." android:textstyle="bold" android:id="@+id/textview3" android:textsize="70sp" android:layout_above="@+id/textview4" android:layout_alignleft="@+id/textview4" android:layout_alignstart="@+id/textview4" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="stop beingness lazy , outside bruh >.>" android:textsize="14sp" android:textcolor="#7f8c8d" android:id="@+id/textview4" android:layout_alignparentbottom="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true" /> </relativelayout>

fixed it, issue named image default, not allowed in android. screw resources class.

java android xml android-fragments build.gradle

No comments:

Post a Comment