Categories
discuss

Is there a way to return the top or second parent element of a specified element using JavaScript?

I would like to get the top parent element (section) of a myLI id.

My HTML code is:

<section>
    <div>
        <ul>
          <li id="myLI">Coffee</li>
          <li>Tea</li>
        </ul>

    </div>
</section>

My code is:

var x = document.getElementById("myLI").parentElement.nodeName;

My code returns UL but I would like for it to return section.

Answer

If you want to target the parent by tagName you could use .closest(selector); like :

var x = document.getElementById("myLI").closest('section');

NOTE : Take a look to the Browser compatibility section.

Hope this helps.

var x = document.getElementById("myLI").closest('section');

console.log(x.tagName);
<section>
    <div>
        <ul>
          <li id="myLI">Coffee</li>
          <li>Tea</li>
        </ul>

    </div>
</section>
Categories
discuss

Generics: Type as property name

Is it possible with generics to pass an object for usage as not only the type, but as the key?

interface store {
  category: string
}

interface ajaxResponse<T> {
  data: ajaxData<T>
  errors: string[]
  success: boolean
}

interface ajaxData<T> {
  rewards: {
    amount: number
    error: string
  }
  T: T
}

function get<T>(url): Promise<ajaxResponse<T>> {
    // make ajax GET request
    // return json object
}

let res = await get<store>('/my/url')

res.data.store.category

When I do that, it says

Property ‘store’ does not exist on type ‘ajaxData’

Is there a way for me to access that property? It works once compiled since all that is removed, but how can I get it working in the editor?

Edit

After thinking about it, I think I don’t want the interface and the property to be the same. I think I would want to use an interface with name x, so maybe something like this:

let res1 = await get<storeA, 'category'>('/my/url1')
let res2 = await get<storeB, 'catList'>('/my/url2')

res1.data.category.category
res2.data.catList.categories

Answer

Yes if you have property name as explicit literal type, you can declare a type having property with that name by using mapped type syntax:

type A<T, PropertyName extends string> = {[P in PropertyName]: T}

So the complete example should look like

interface store {
  category: string
}

interface ajaxResponse<T, PropertyName extends string> {
  data: ajaxData<T, PropertyName>
  errors: string[]
  success: boolean
}

type ajaxData<T, PropertyName extends string> = {
  rewards: {
    amount: number
    error: string
  }
} & {[P in PropertyName]: T}




function get<T, PropertyName extends string>(url): Promise<ajaxResponse<T, PropertyName>> {
    // make ajax GET request
    // return json object
  return null;
}

async function test() {
  let res = await get<store, 'store'>('/my/url')

  res.data.store.category
}
Categories
discuss

Error: Failed to run “javac -version”, make sure that you have a JDK Installed

Error: Failed to run “javac -version”, make sure that you have a JDK
installed. You can get it from:
http://www.oracle.com/technetwork/java/javase/downloads. Your
JAVA_HOME is invalid: C:Program FilesJavajdk1.8.0_152;

[ERROR] An error occurred while running cordova run android (exit code
1)

My JAVA_HOME : C:Program FilesJavajdk1.8.0_152;C:Program FilesJavajdk1.8.0_152bin;

ANDROID_HOME: C:UsersFelipeAppDataLocalAndroidsdk;

Path: %SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;%SYSTEMROOT%System32WindowsPowerShellv1.0;%JAVA_HOME%bin;%ANDROID_HOME%tools;%ANDROID_HOME%platform-tools;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)ATI TechnologiesATI.ACECore-Static;C:Program Files (x86)Windows LiveShared;C:Program Files (x86)SkypePhone;C:Program FilesPuTTY;C:Program FilesGitcmd;C:Program FilesGitmingw64bin;C:Program FilesGitusrbin;C:Program Filesnodejs;C:apache-ant-1.9.6bin;%JAVA_HOME%;C:UsersFelipeAppDataLocalAndroidsdkbuild-tools27.0.0;C:UsersFelipeAppDataLocalAndroidsdktools;

Any idea why returns me this error when i try to use ionic cordova run android?

Answer

Search for “edit environment variables” in start.
and under user variables add a new variable with name “JAVA_HOME” and value with path_to_jdk_bin.

like this

enter image description here

Now under system variables, the path variable should contain(add if not added) the entry %JAVA_HOME%.

Like this

enter image description here

Categories
discuss

Android studio error java.lang.IllegalArgumentException: Resource name cannot be empty

I am attempting to reopen an older Android Studio project in version 3.0.

It compiles and launches just fine, but if I try to edit a layout in the layout designer, it won’t load and simply keeps saying that it is waiting for the build to finish (which it has).

When I look in the IDE errors, I see this error:

provider: org.jetbrains.android.augment.AndroidPsiAugmentProvider@2180343: Resource name cannot be empty.

As I look though the trace info, I see nothing that points back at my project.

Any suggestions?

Here is the full trace output:

provider: org.jetbrains.android.augment.AndroidPsiAugmentProvider@2180343: Resource name cannot be empty.
java.lang.IllegalArgumentException: Resource name cannot be empty.
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
    at com.android.ide.common.res2.ResourceItem.<init>(ResourceItem.java:115)
    at com.android.ide.common.res2.IdGeneratingResourceParser$IdResourceItem.<init>(IdGeneratingResourceParser.java:202)
    at com.android.ide.common.res2.IdGeneratingResourceParser.<init>(IdGeneratingResourceParser.java:81)
    at com.android.ide.common.res2.ResourceSet.createResourceFile(ResourceSet.java:456)
    at com.android.ide.common.res2.ResourceSet.createFileAndItems(ResourceSet.java:111)
    at com.android.ide.common.res2.ResourceSet.handleNewFile(ResourceSet.java:257)
    at com.android.ide.common.res2.ResourceSet.handleNewFile(ResourceSet.java:52)
    at com.android.ide.common.res2.DataSet.loadFile(DataSet.java:275)
    at com.android.tools.idea.res.ResourceFolderRepository$InitialScanState.loadFile(ResourceFolderRepository.java:325)
    at com.android.tools.idea.res.ResourceFolderRepository.scanFileResourceFile(ResourceFolderRepository.java:524)
    at com.android.tools.idea.res.ResourceFolderRepository.scanFileResourceFolder(ResourceFolderRepository.java:477)
    at com.android.tools.idea.res.ResourceFolderRepository.scanResFolder(ResourceFolderRepository.java:449)
    at com.android.tools.idea.res.ResourceFolderRepository.scanRemainingFiles(ResourceFolderRepository.java:375)
    at com.android.tools.idea.res.ResourceFolderRepository.<init>(ResourceFolderRepository.java:119)
    at com.android.tools.idea.res.ResourceFolderRepository.create(ResourceFolderRepository.java:152)
    at com.android.tools.idea.res.ResourceFolderRegistry.get(ResourceFolderRegistry.java:76)
    at com.android.tools.idea.res.ResourceFolderRegistry.get(ResourceFolderRegistry.java:64)
    at com.android.tools.idea.res.ModuleResourceRepository.create(ModuleResourceRepository.java:95)
    at com.android.tools.idea.res.ResourceRepositories.lambda$getModuleResources$2(ResourceRepositories.java:98)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:942)
    at com.android.tools.idea.res.ResourceRepositories.getModuleResources(ResourceRepositories.java:95)
    at com.android.tools.idea.res.ModuleResourceRepository.findModuleResources(ModuleResourceRepository.java:71)
    at com.android.tools.idea.res.ModuleResourceRepository.getOrCreateInstance(ModuleResourceRepository.java:59)
    at com.android.tools.idea.res.ProjectResourceRepository.computeRepositories(ProjectResourceRepository.java:81)
    at com.android.tools.idea.res.ProjectResourceRepository.create(ProjectResourceRepository.java:73)
    at com.android.tools.idea.res.ResourceRepositories.lambda$getProjectResources$1(ResourceRepositories.java:83)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:942)
    at com.android.tools.idea.res.ResourceRepositories.getProjectResources(ResourceRepositories.java:80)
    at com.android.tools.idea.res.ProjectResourceRepository.findProjectResources(ProjectResourceRepository.java:63)
    at com.android.tools.idea.res.ProjectResourceRepository.getOrCreateInstance(ProjectResourceRepository.java:51)
    at com.android.tools.idea.res.AppResourceRepository.computeRepositories(AppResourceRepository.java:156)
    at com.android.tools.idea.res.AppResourceRepository.create(AppResourceRepository.java:123)
    at com.android.tools.idea.res.ResourceRepositories.lambda$getAppResources$0(ResourceRepositories.java:68)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:942)
    at com.android.tools.idea.res.ResourceRepositories.getAppResources(ResourceRepositories.java:65)
    at com.android.tools.idea.res.AppResourceRepository.findAppResources(AppResourceRepository.java:117)
    at com.android.tools.idea.res.AppResourceRepository.getOrCreateInstance(AppResourceRepository.java:99)
    at org.jetbrains.android.dom.converters.ResourceReferenceConverter.getResourceTypesInCurrentModule(ResourceReferenceConverter.java:262)
    at org.jetbrains.android.augment.AndroidPsiAugmentProvider.getAugments(AndroidPsiAugmentProvider.java:67)
    at com.intellij.psi.augment.PsiAugmentProvider.lambda$collectAugments$0(PsiAugmentProvider.java:93)
    at com.intellij.psi.augment.PsiAugmentProvider.forEach(PsiAugmentProvider.java:137)
    at com.intellij.psi.augment.PsiAugmentProvider.collectAugments(PsiAugmentProvider.java:92)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.getAllInnerClasses(ClassInnerStuffCache.java:139)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.lambda$getInnerClasses$3(ClassInnerStuffCache.java:72)
    at com.intellij.psi.util.CachedValuesManager.lambda$getCachedValue$0(CachedValuesManager.java:141)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:222)
    at com.intellij.psi.impl.PsiCachedValue.getValueWithLock(PsiCachedValue.java:60)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:137)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:127)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.getInnerClasses(ClassInnerStuffCache.java:71)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.getInnerClassesMap(ClassInnerStuffCache.java:182)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.lambda$findInnerClassByName$6(ClassInnerStuffCache.java:102)
    at com.intellij.psi.util.CachedValuesManager.lambda$getCachedValue$0(CachedValuesManager.java:141)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:222)
    at com.intellij.psi.impl.PsiCachedValue.getValueWithLock(PsiCachedValue.java:60)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:137)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:127)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.findInnerClassByName(ClassInnerStuffCache.java:101)
    at com.intellij.psi.impl.source.PsiClassImpl.findInnerClassByName(PsiClassImpl.java:396)
    at org.jetbrains.android.util.AndroidResourceUtil.findResourceFieldsFromClass(AndroidResourceUtil.java:190)
    at org.jetbrains.android.util.AndroidResourceUtil.findResourceFields(AndroidResourceUtil.java:182)
    at org.jetbrains.android.util.AndroidResourceUtil.findResourceFields(AndroidResourceUtil.java:168)
    at org.jetbrains.android.AndroidGotoRelatedProvider.collectRelatedJavaFiles(AndroidGotoRelatedProvider.java:182)
    at org.jetbrains.android.AndroidGotoRelatedProvider.getLazyItemsForXmlFile(AndroidGotoRelatedProvider.java:112)
    at org.jetbrains.android.AndroidLineMarkerProvider.getMarkerInfo(AndroidLineMarkerProvider.java:91)
    at org.jetbrains.android.AndroidLineMarkerProvider.doGetLineMarkerInfo(AndroidLineMarkerProvider.java:52)
    at org.jetbrains.android.AndroidLineMarkerProvider.collectSlowLineMarkers(AndroidLineMarkerProvider.java:37)
    at com.intellij.codeInsight.daemon.impl.LineMarkersPass.queryProviders(LineMarkersPass.java:209)
    at com.intellij.codeInsight.daemon.impl.LineMarkersPass.lambda$doCollectInformation$3(LineMarkersPass.java:111)
    at com.intellij.codeInsight.daemon.impl.Divider.divideInsideAndOutsideInOneRoot(Divider.java:96)
    at com.intellij.codeInsight.daemon.impl.LineMarkersPass.doCollectInformation(LineMarkersPass.java:106)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:70)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$null$1(PassExecutorService.java:438)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1156)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:431)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:556)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:501)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:430)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:406)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:142)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:242)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:404)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:165)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)


java.lang.IllegalArgumentException: Resource name cannot be empty.
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
    at com.android.ide.common.res2.ResourceItem.<init>(ResourceItem.java:115)
    at com.android.ide.common.res2.IdGeneratingResourceParser$IdResourceItem.<init>(IdGeneratingResourceParser.java:202)
    at com.android.ide.common.res2.IdGeneratingResourceParser.<init>(IdGeneratingResourceParser.java:81)
    at com.android.ide.common.res2.ResourceSet.createResourceFile(ResourceSet.java:456)
    at com.android.ide.common.res2.ResourceSet.createFileAndItems(ResourceSet.java:111)
    at com.android.ide.common.res2.ResourceSet.handleNewFile(ResourceSet.java:257)
    at com.android.ide.common.res2.ResourceSet.handleNewFile(ResourceSet.java:52)
    at com.android.ide.common.res2.DataSet.loadFile(DataSet.java:275)
    at com.android.tools.idea.res.ResourceFolderRepository$InitialScanState.loadFile(ResourceFolderRepository.java:325)
    at com.android.tools.idea.res.ResourceFolderRepository.scanFileResourceFile(ResourceFolderRepository.java:524)
    at com.android.tools.idea.res.ResourceFolderRepository.scanFileResourceFolder(ResourceFolderRepository.java:477)
    at com.android.tools.idea.res.ResourceFolderRepository.scanResFolder(ResourceFolderRepository.java:449)
    at com.android.tools.idea.res.ResourceFolderRepository.scanRemainingFiles(ResourceFolderRepository.java:375)
    at com.android.tools.idea.res.ResourceFolderRepository.<init>(ResourceFolderRepository.java:119)
    at com.android.tools.idea.res.ResourceFolderRepository.create(ResourceFolderRepository.java:152)
    at com.android.tools.idea.res.ResourceFolderRegistry.get(ResourceFolderRegistry.java:76)
    at com.android.tools.idea.res.ResourceFolderRegistry.get(ResourceFolderRegistry.java:64)
    at com.android.tools.idea.res.ModuleResourceRepository.create(ModuleResourceRepository.java:95)
    at com.android.tools.idea.res.ResourceRepositories.lambda$getModuleResources$2(ResourceRepositories.java:98)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:942)
    at com.android.tools.idea.res.ResourceRepositories.getModuleResources(ResourceRepositories.java:95)
    at com.android.tools.idea.res.ModuleResourceRepository.findModuleResources(ModuleResourceRepository.java:71)
    at com.android.tools.idea.res.ModuleResourceRepository.getOrCreateInstance(ModuleResourceRepository.java:59)
    at com.android.tools.idea.res.ProjectResourceRepository.computeRepositories(ProjectResourceRepository.java:81)
    at com.android.tools.idea.res.ProjectResourceRepository.create(ProjectResourceRepository.java:73)
    at com.android.tools.idea.res.ResourceRepositories.lambda$getProjectResources$1(ResourceRepositories.java:83)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:942)
    at com.android.tools.idea.res.ResourceRepositories.getProjectResources(ResourceRepositories.java:80)
    at com.android.tools.idea.res.ProjectResourceRepository.findProjectResources(ProjectResourceRepository.java:63)
    at com.android.tools.idea.res.ProjectResourceRepository.getOrCreateInstance(ProjectResourceRepository.java:51)
    at com.android.tools.idea.res.AppResourceRepository.computeRepositories(AppResourceRepository.java:156)
    at com.android.tools.idea.res.AppResourceRepository.create(AppResourceRepository.java:123)
    at com.android.tools.idea.res.ResourceRepositories.lambda$getAppResources$0(ResourceRepositories.java:68)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:942)
    at com.android.tools.idea.res.ResourceRepositories.getAppResources(ResourceRepositories.java:65)
    at com.android.tools.idea.res.AppResourceRepository.findAppResources(AppResourceRepository.java:117)
    at com.android.tools.idea.res.AppResourceRepository.getOrCreateInstance(AppResourceRepository.java:99)
    at org.jetbrains.android.resourceManagers.LocalResourceManager.getResourceNames(LocalResourceManager.java:261)
    at org.jetbrains.android.resourceManagers.ResourceManager.getResourceNames(ResourceManager.java:349)
    at org.jetbrains.android.augment.ResourceTypeClassBase.buildResourceFields(ResourceTypeClassBase.java:40)
    at org.jetbrains.android.augment.ResourceTypeClass.buildLocalResourceFields(ResourceTypeClass.java:30)
    at org.jetbrains.android.augment.AndroidPsiAugmentProvider.getAugments(AndroidPsiAugmentProvider.java:107)
    at com.intellij.psi.augment.PsiAugmentProvider.lambda$collectAugments$0(PsiAugmentProvider.java:93)
    at com.intellij.psi.augment.PsiAugmentProvider.forEach(PsiAugmentProvider.java:137)
    at com.intellij.psi.augment.PsiAugmentProvider.collectAugments(PsiAugmentProvider.java:92)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.getAllFields(ClassInnerStuffCache.java:125)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.lambda$getFields$1(ClassInnerStuffCache.java:60)
    at com.intellij.psi.util.CachedValuesManager.lambda$getCachedValue$0(CachedValuesManager.java:141)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:222)
    at com.intellij.psi.impl.PsiCachedValue.getValueWithLock(PsiCachedValue.java:60)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:137)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:127)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.getFields(ClassInnerStuffCache.java:59)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.getFieldsMap(ClassInnerStuffCache.java:145)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.lambda$findFieldByName$4(ClassInnerStuffCache.java:82)
    at com.intellij.psi.util.CachedValuesManager.lambda$getCachedValue$0(CachedValuesManager.java:141)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:222)
    at com.intellij.psi.impl.PsiCachedValue.getValueWithLock(PsiCachedValue.java:60)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:137)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:127)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.findFieldByName(ClassInnerStuffCache.java:80)
    at com.intellij.psi.impl.source.PsiClassImpl.findFieldByName(PsiClassImpl.java:362)
    at org.jetbrains.android.util.AndroidResourceUtil.findResourceFieldsFromClass(AndroidResourceUtil.java:195)
    at org.jetbrains.android.util.AndroidResourceUtil.findResourceFields(AndroidResourceUtil.java:182)
    at org.jetbrains.android.util.AndroidResourceUtil.findResourceFields(AndroidResourceUtil.java:168)
    at org.jetbrains.android.AndroidGotoRelatedProvider.collectRelatedJavaFiles(AndroidGotoRelatedProvider.java:182)
    at org.jetbrains.android.AndroidGotoRelatedProvider.getLazyItemsForXmlFile(AndroidGotoRelatedProvider.java:112)
    at org.jetbrains.android.AndroidLineMarkerProvider.getMarkerInfo(AndroidLineMarkerProvider.java:91)
    at org.jetbrains.android.AndroidLineMarkerProvider.doGetLineMarkerInfo(AndroidLineMarkerProvider.java:52)
    at org.jetbrains.android.AndroidLineMarkerProvider.collectSlowLineMarkers(AndroidLineMarkerProvider.java:37)
    at com.intellij.codeInsight.daemon.impl.LineMarkersPass.queryProviders(LineMarkersPass.java:209)
    at com.intellij.codeInsight.daemon.impl.LineMarkersPass.lambda$doCollectInformation$3(LineMarkersPass.java:111)
    at com.intellij.codeInsight.daemon.impl.Divider.divideInsideAndOutsideInOneRoot(Divider.java:96)
    at com.intellij.codeInsight.daemon.impl.LineMarkersPass.doCollectInformation(LineMarkersPass.java:106)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:70)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$null$1(PassExecutorService.java:438)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1156)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:431)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:556)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:501)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:430)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:406)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:142)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:242)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:404)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:165)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Update: I have not found a solution yet, but a coworker working on another project (from which I forked my project) has just had the same thing happen to him. This leads me to think this may be project specific. However, none of the error trace shows anything in our project. This obviously makes it hard to diagnose.

Answer

This error can occur when you update to Android Studio 3.0. It doesn’t affect your ability to build a project, but the error does not allow you to visually see your xml layout files. You will also get the error when committing files to GIT, but you can still commit and push.

What I found in one of my projects is that a file was added to the “menu” folder automatically upon Android Studio upgrade, and the file had no name. It was named simply “.xml”. All you need to do is delete the file and clean your project, allowing a new build of the project. That should take care of the issue.

Categories
discuss

React Native Image not showing, How do i fix?

I was wondering why my image is not showing. What I want is for my image to be in the background with my two buttons on the bottom, over the image. I am using react native, with the IDE ‘Deco’ for apps. Right now there is no image showing at all:

import React, { Component } from 'react';
import { Button,Alert, TouchableOpacity,Image, Dimensions } from 'react-native'

import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} from 'react-native';

class Project extends Component {
  render() {
    return (
      <View style={{backgroundColor: '#375D81', flex: 1}}>
        <Image source={{uri: 'https://upload.wikimedia.org/wikipedia/commons/f/f0/Everest_North_Face_toward_Base_Camp_Tibet_Luca_Galuzzi_2006_edit_1.jpg'}}/>
         <View style = {styles.container}>
           <TouchableOpacity style = {styles.buttonText1} onPress={() => { Alert.alert('You tapped the button!')}}>
             <Text style={styles.text}> 
              Button 1
             </Text>
           </TouchableOpacity>
           
           <TouchableOpacity style = {styles.buttonText2} onPress={() => { Alert.alert('You tapped the button!')}}>
             <Text style= {styles.text}>
              Button 2
             </Text>
           </TouchableOpacity>
           
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
 main: {
   backgroundColor: 'blue'
 },
 text: {
 alignItems : 'center'
               
 },
 container: {
  alignItems: 'center',
  flex: 1,
 },
  buttonText1: {
      borderWidth: 1,
      padding: 25,      
      borderColor: 'black',
      backgroundColor: '#C4D7ED',
      alignItems: 'center',
      position: 'absolute',
      bottom: 0,
      width: Dimensions.get('window').width / 2,
      height: Dimensions.get('window').height / 8,
      left: 0,
   },
    buttonText2: {
      borderWidth: 1,
      padding: 25,      
      borderColor: 'black',
      backgroundColor: '#C4D7ED',
      alignItems: 'center',
      position: 'absolute',
      bottom: 0,
      width: Dimensions.get('window').width / 2,
      height: Dimensions.get('window').height / 8,
      right: 0,
   }
});

AppRegistry.registerComponent('Project', () => Project);

Answer

make some width and height for the image..

 <Image
   style={{width: 50, height: 50}}
   source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}}
   resizeMode={'cover'} // cover or contain its upto you view look
   />

Try to undesrtand this…

Here i mentioned width and height… you can make it ‘100%’ its upto you…

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..