» »

[Android SDK]+[NetBeans][verzija 7.1.1]Project Compile Error

[Android SDK]+[NetBeans][verzija 7.1.1]Project Compile Error

KernelPanic ::

Spostovani!

V NetBeans sem kreiral nov Android projekt, dodal activity in stvar se prevede brez problemov. Nato sem za ta activity ustvaril style xml dokument, kreiral folder "styles" in skopiral omenjeni style dokument v ta folder, da bi imel urejen projekt (styles v svoji mapi, layouts v svoji mapi, sourci v src folderju, ...) in sedaj dobim sledec error, ko probam prevesti projekt:
clean:
Deleting directory C:\Users\xxx\Documents\Projects\Android\xxx.com\project\bin
Deleting directory C:\Users\xxx\Documents\Projects\Android\xxx.com\project\gen
Gathering info for project...
Android SDK Tools Revision 16
Project Target: Android 4.0.3
API level: 15
------------------
Resolving library dependencies:
No library dependencies.

------------------

WARNING: No minSdkVersion value set. Application will install on all Android versions.
Creating output directories if needed...
Created dir: C:\Users\xxx\Documents\Projects\Android\xxx.com\project\bin
Created dir: C:\Users\xxx\Documents\Projects\Android\xxx.com\project\bin\res
Created dir: C:\Users\xxx\Documents\Projects\Android\xxx.com\project\gen
Created dir: C:\Users\xxx\Documents\Projects\Android\xxx.com\project\bin\classes
----------
Handling aidl files...
No AIDL files to compile.
----------
Handling RenderScript files...
No RenderScript files to compile.
----------
Handling Resources...
Generating resource IDs...
invalid resource directory name: C:\Users\xxx\Documents\Projects\Android\xxx.com\project\res/style
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:560: The following error occurred while executing this line:
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:589: null returned: 1
BUILD FAILED (total time: 0 seconds)
Zakaj mi direktorija noce "pozreti"?

Lp,
M.

KernelPanic ::

Ok, v Android SDK docs sem naletel na sledeco spletno stran:http://developer.android.com/guide/topi.... V njej pise, da imas na voljo le 8 resource tipov, v katerih ni posebej definiran Style. Torej, datoteko sem premaknil v res/values folder, sedaj mi pa compiler zajamra, da ne najde R.styles.myclass, vendar v zgeneriranem R.java je moj style viden:
clean:
Deleting directory C:\Users\xxx\Documents\Projects\Android\xxx.com\xxx\bin
Deleting directory C:\Users\xxx\Documents\Projects\Android\xxx.com\xxx\gen
Gathering info for xxx...
Android SDK Tools Revision 16
Project Target: Android 4.0.3
API level: 15
------------------
Resolving library dependencies:
No library dependencies.

------------------

WARNING: No minSdkVersion value set. Application will install on all Android versions.
Creating output directories if needed...
Created dir: C:\Users\xxx\Documents\Projects\Android\xxx.com\xxx\bin
Created dir: C:\Users\xxx\Documents\Projects\Android\xxx.com\xxx\bin\res
Created dir: C:\Users\xxx\Documents\Projects\Android\xxx.com\xxx\gen
Created dir: C:\Users\xxx\Documents\Projects\Android\xxx.com\xxx\bin\classes
----------
Handling aidl files...
No AIDL files to compile.
----------
Handling RenderScript files...
No RenderScript files to compile.
----------
Handling Resources...
Generating resource IDs...
Compiling 3 source files to C:\Users\xxx\Documents\Projects\Android\xxx.com\xxx\bin\classes
C:\Users\xxx\Documents\Projects\Android\xxx.com\xxx\src\com\spletnatrgovina\oljedirekt\activitySplashScreen.java:40: error: cannot find symbol
R.style.Style_ActivtySplashScreen));
symbol: variable Style_ActivtySplashScreen
location: class style
1 error
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:602: The following error occurred while executing this line:
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:622: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

Marat ::

Kot si ugotovil moraš upoštevat Androidova pravila glede map in kaj paše v katero mapo.

kar se pa tiče style xml datoteke, bi ti jo pa verjetno moralo najti pod R.values.imestylea. Potem naredi Project --> Clean in povej če bo delalo.

Lahko je pa tudi problem da ta style dokument ne paše v values, ampak pod layouts ali celo drawable. Probaj še to dvoje, ampak glej da boš vedno po spremembi naredil Project/Clean in pa da boš pri klicanju stylea upošteval kje v resources je ta fajl (npr. R.drawable.imestylea).

Btw, pa ne delat svoje mape style.

Zgodovina sprememb…

  • spremenil: Marat ()

Mavrik ::

styles.xml seveda spada v mapo res\values\ in vse vrednosti so dostopne pod R.style.[id_stila] .

V kolikor tvoj R.java ne vključuje teh vnosov, ti nekaj bluzi build proces - kar je pri tem da uporabljaš NetBeans niti ni tako čudno (Android SDK je pisan z Eclipsom v mislih) - premisli o menjavi na Eclipse da se ne boš cel čas ukvarjal z bedarijami okoli build procesa.

Kaj pa sploh hočeš doseči? Kolikor vem trenutno spreminjanje stilov v kodi itak sploh še ni podprto, tak da ti dostop s kode ne pomaga nič - stile moraš nastaviti s

<View style="@style/<ime stila>" />
The truth is rarely pure and never simple.

Zgodovina sprememb…

  • spremenil: Mavrik ()

KernelPanic ::

Torej, zacel sem delati na svoji prvi aplikaciji in bi rad na zacetku uvedel t.i. Splash Screen. Ker Android SDK nima posebnega razreda za taksen GUI Element (Widget iz Qt terminologije ter View iz Android terminologije), sem po netu pobrskal za primeri in nasel sem enega enostavnega na http://blog.iangclifton.com/2011/01/01/.... Ta primer instancira dialog, ga ustrezno modificira (odstrani mu frame, itd ...) ter nastavi custom style, kot je razvidno iz primera. Ker ta primer ni dosegljiv kot arhiviran projekt, sem kreiral nov projekt v NetBeans in kodiram glede na primer. Vendar mi nikakor ne najde style-a za splash dialog. Vendar, ce pogledas generiran R.java objekt, moj custom style je notri:
/* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * aapt tool from the resource data it found.  It
 * should not be modified by hand.
 */

package com.xxx.projekt;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int ic_launcher=0x7f020000;
    }
    public static final class layout {
        public static final int layout_activity_splashscreen=0x7f030000;
    }
    public static final class string {
        public static final int app_name_si=0x7f040000;
    }
    public static final class style {
        public static final int Style_ActivtySplashScreen=0x7f050000;
    }
}
Ima mogoce kdo idejo, zakaj ne morem dostopati do memberja Style_ActivtySplashScreen, saj je public!?

Zgodovina sprememb…

Mavrik ::

Aha, za Dialoge se pa da to delat ja.

Well, ena čist bedna fora, ki se meni pogosto dogaja: pogosto se zgodi da Eclipse avtomatsko importa "android.R" razred (ki ima exporte za resource, ki so že vgrajeni v Android) namesto tvojega "R" razrega in potem maš točno take probleme. Poglej importe v classu kjer hočeš to uporabljati :)
The truth is rarely pure and never simple.

KernelPanic ::

No sedaj sem pa dodal nov xml v generiranem R.java je deklariran:
public static final int citemmerchanfisecategory=0x7f030004;
, vendar ga v spodnji vrstici NetBeans ne najde:
            myView=li.inflate(R.layout.citemmerchandisecategory,
                              null);
Ta vrstica javi napako:
error: package R does not exist
myView=li.inflate(R.layout.citemmerchandisecategory,
Zakaj je sedaj prislo do tega, mogoce kdo ve?


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

[android] vstavljanje slike

Oddelek: Programiranje
71247 (1144) messi
»

[Android]GridView vprasanje

Oddelek: Programiranje
12954 (835) KernelPanic

noviteti.com?

Oddelek: Pomoč in nasveti
51194 (1098) OmegaBlue
»

Obetajo se nam domene .xxx

Oddelek: Novice / Omrežja / internet
307976 (7168) B-D_
»

namezero.com ?

Oddelek: Omrežja in internet
101325 (1096) tejo

Več podobnih tem