16.9 Creating getScaledBitmap()


#1

After creating the code for the bitmap on 16.9 I ran the program and for some reason none of my imports can be recognized. Not appcomatactivity or any of the imports can be recognized. When I press (alt + enter) it says set up JDK.


#2

Screenshot of my imports. I’m assuming that the problem is with the sdk somehow being thrown off but I don’t know what is causing the problem. Also, when I run the debugger the app works fine, so I can’t get an error in the log.


#3

Screenshot asking to configure JDK when pressing (alt + enter).


#4

build.gradle:

apply plugin: ‘com.android.application’

android {
compileSdkVersion 26
defaultConfig {
applicationId "com.bignerdranch.android.criminalintent"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner”
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro
}
}
}

dependencies {
implementation fileTree(dir: ‘libs’, include: [’*.jar’])
implementation 'com.android.support:appcompat-v7:26.1.0’
implementation 'com.android.support:recyclerview-v7:26.1.0’
implementation 'com.android.support.constraint:constraint-layout:1.0.2’
testImplementation 'junit:junit:4.12’
androidTestImplementation 'com.android.support.test:runner:1.0.1’
androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.1’
}


#5

Android Manifest:

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".CrimeListActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".CrimePagerActivity"
        android:parentActivityName=".CrimeListActivity">
    </activity>
    <provider
        android:authorities="com.bignerdranch.android.criminalintent.fileprovider"
        android:name="android.support.v4.content.FileProvider"
        android:exported="false"
        android:grantUriPermissions="true">

        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/files" />
    </provider>

</application>

#6

Did you solve your problem?
I found something like this : StackOverFlow link.


#7

Happy Holidays and thank you for the reply. It seems I may have created another problem trying another method to get the program to work. I ended up at the sdk update page within file>settings>behaviors>sdk. I’m running Andriod 26.1.0. As far as I can remember its always been the same since I ran into trouble with the mismatch in the recycleview. When I try to download the tools it says the package is unavailable. In the ‘show package details list’ I don’t see any tools for version 26.1.0 but I do see one for 26.0.1.

Do I switch to 26.0.1?

Look at the log on this pic at the bootom. on the left is where I click:

This is the SDK page 26.0.1 is seen but not 26.1.0:

Your first link solved the initial problem but I made the problem worst trying to fix it alone:

Most of the imports show now except the OS and content. This is my build.gradle:

apply plugin: ‘com.android.application’

android {
compileSdkVersion 26
defaultConfig {
applicationId “com.bignerdranch.android.criminalintent”
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName “1.0”
testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner”
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
buildToolsVersion ‘26.1.0’
}

dependencies {
implementation fileTree(include: [’*.jar’], dir: ‘libs’)
implementation ‘com.android.support:appcompat-v7:26.1.0’
implementation ‘com.android.support:recyclerview-v7:26.1.0’
implementation ‘com.android.support.constraint:constraint-layout:1.0.2’
testImplementation ‘junit:junit:4.12’
androidTestImplementation ‘com.android.support.test:runner:1.0.1’
androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.1’
}


#8

I tried (alt+enter) on Bundle, to see if it would import and met the following list of choices. I chose Gradle Project Sync Failed… Show log in explorer:

And this is the log error in explorer: I see a strange error in the log and another which also points to tools:

at org.jetbrains.android.inspections.lint.SetAttributeQuickFix.apply(SetAttributeQuickFix.java:85)
at com.android.tools.idea.uibuilder.error.NlIssue$NlLintIssueWrapper.lambda$null$0(NlIssue.java:316)

This stands out to me. I remember Lint from the earlier part of the book and I believe its associated with error correction and the compiler. I will go back and read up on lint and I will continue to research this error.
This is the entire Log in case I’m missing the target:

2017-12-23 00:33:04,331 [se-915-b01] ERROR - l.source.tree.CompositeElement - Android Studio 3.0.1 Build #AI-171.4443003
2017-12-23 00:33:04,331 [se-915-b01] ERROR - l.source.tree.CompositeElement - JDK: 1.8.0_152-release
2017-12-23 00:33:04,331 [se-915-b01] ERROR - l.source.tree.CompositeElement - VM: OpenJDK 64-Bit Server VM
2017-12-23 00:33:04,331 [se-915-b01] ERROR - l.source.tree.CompositeElement - Vendor: JetBrains s.r.o
2017-12-23 00:33:04,331 [se-915-b01] ERROR - l.source.tree.CompositeElement - OS: Windows 10
2017-12-23 00:33:04,331 [se-915-b01] ERROR - l.source.tree.CompositeElement - Last Action: EditorBackSpace
2017-12-23 00:33:04,331 [se-915-b01] ERROR - l.source.tree.CompositeElement - Current Command: Execute Fix: Set contentDescription
2017-12-23 00:33:04,331 [se-915-b01] ERROR - l.source.tree.CompositeElement - Threading assertion. Under write: false; Thread.holdsLock(PsiLock.LOCK): true; wrapper: XmlTag:ImageView; wrapper.isPhysical(): true; fileElement: Element(FILE); psiFile: XmlFile:fragment_crime.xml; psiFile.getViewProvider(): SingleRootFileViewProvider{myVirtualFile=file://C:/Users/JB/AndroidStudioProjects/CriminalIntent/app/src/main/res/layout/fragment_crime.xml, content=com.intellij.psi.SingleRootFileViewProvider$PsiFileContent@4074414a}; psiFile.isPhysical(): true; nonPhysicalOrInjected: false
com.intellij.openapi.diagnostic.Logger$EmptyThrowable
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:134)
at com.intellij.psi.impl.source.tree.CompositeElement.assertThreading(CompositeElement.java:122)
at com.intellij.psi.impl.source.tree.CompositeElement.clearCaches(CompositeElement.java:109)
at com.intellij.psi.impl.source.xml.XmlTagImpl.clearCaches(XmlTagImpl.java:151)
at com.intellij.psi.impl.source.tree.CompositeElement.subtreeChanged(CompositeElement.java:92)
at com.intellij.psi.impl.source.tree.ChangeUtil$1.runInner(ChangeUtil.java:177)
at com.intellij.pom.impl.PomTransactionBase.run(PomTransactionBase.java:46)
at com.intellij.pom.core.impl.PomModelImpl.runTransaction(PomModelImpl.java:158)
at com.intellij.psi.impl.source.tree.ChangeUtil.prepareAndRunChangeAction(ChangeUtil.java:167)
at com.intellij.psi.impl.source.tree.CompositeElement.addChild(CompositeElement.java:646)
at com.intellij.psi.impl.source.codeStyle.CodeEditUtil.markToReformatBeforeOrInsertWhitespace(CodeEditUtil.java:321)
at com.intellij.psi.impl.source.codeStyle.CodeEditUtil.makePlaceHolderBetweenTokens(CodeEditUtil.java:294)
at com.intellij.psi.impl.source.codeStyle.CodeEditUtil.addChildren(CodeEditUtil.java:76)
at com.intellij.psi.impl.source.tree.CompositeElement.addInternal(CompositeElement.java:530)
at com.intellij.psi.impl.source.xml.XmlTagImpl.access$901(XmlTagImpl.java:78)
at com.intellij.psi.impl.source.xml.XmlTagImpl$InsertAttributeTransaction.runInner(XmlTagImpl.java:1302)
at com.intellij.pom.impl.PomTransactionBase.run(PomTransactionBase.java:46)
at com.intellij.pom.core.impl.PomModelImpl.runTransaction(PomModelImpl.java:158)
at com.intellij.psi.impl.source.xml.XmlTagImpl.addInternal(XmlTagImpl.java:1095)
at com.intellij.psi.impl.source.xml.XmlTagImpl.addInternal(XmlTagImpl.java:1042)
at com.intellij.psi.impl.source.tree.CompositePsiElement.addInnerBefore(CompositePsiElement.java:320)
at com.intellij.psi.impl.source.tree.CompositePsiElement.add(CompositePsiElement.java:151)
at com.intellij.psi.impl.source.xml.XmlTagImpl.setAttribute(XmlTagImpl.java:966)
at com.intellij.psi.impl.source.xml.XmlTagImpl.setAttribute(XmlTagImpl.java:978)
at org.jetbrains.android.inspections.lint.SetAttributeQuickFix.apply(SetAttributeQuickFix.java:85)
at com.android.tools.idea.uibuilder.error.NlIssue$NlLintIssueWrapper.lambda$null$0(NlIssue.java:316)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:149)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:109)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:99)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:85)
at com.android.tools.idea.uibuilder.error.NlIssue$NlLintIssueWrapper.lambda$createQuickFixRunnable$1(NlIssue.java:314)
at com.android.tools.idea.uibuilder.error.IssueView$FixEntry.lambda$new$0(IssueView.java:291)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6541)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6306)
at java.awt.Container.processEvent(Container.java:2237)
at java.awt.Component.dispatchEventImpl(Component.java:4897)
at java.awt.Container.dispatchEventImpl(Container.java:2295)
at java.awt.Component.dispatchEvent(Component.java:4719)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
at java.awt.Container.dispatchEventImpl(Container.java:2281)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4719)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:737)
at java.awt.EventQueue$4.run(EventQueue.java:735)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:827)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:651)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

I will continue to research @Iscodex, youre information and advice has been 100% accurate and to the point. Thanks for the time and help.


#9

hey, I think, I found a solution.
you can change buildToolsVersion ‘26.1.0’ to buildToolsVersion ‘26.0.1’.Then sync gradle and re-build your project.
Because,The version you’re using has not been released yet.
Check this.


#10

Thank you. I was trying that when you replied. I was told the minimum that 3.0.1 support was 26.0.2 and its in the process of syncing now.


#11

Everything is back to normal. Thanks again:+1:


#12

Excellent topic. Great information here.